This code is throwing an error on the line marked below, can anyone point me in the right direction to why this is throwing an error?
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
SqlDataAdapter dadapter;
DataSet dset;
string sql = "SELECT * from SocoetyMaintan";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dadapter = new SqlDataAdapter(sql, con);
dset = new DataSet();
dadapter.Fill(dset);
DropDownList1.DataSource = dset.Tables[0];
DropDownList1.DataTextField = "FullName";
DropDownList1.DataValueField = "Id";
DropDownList1.DataBind();
GridViewBind();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewBind();
}
public void GridViewBind()
{
dadapter = new SqlDataAdapter("SELECT * from SocoetyMaintan where Id=" + DropDownList1.SelectedValue + "", con);
dset = new DataSet(); //Throwing Error Here
dadapter.Fill(dset);
GridView1.DataSource = dset.Tables[0];
GridView1.DataBind();