protected void Button2_Click1(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=ABHINAV-PC\ABHI;Initial Catalog=swapnil;Integrated Security=True");
con.Open();
if (DropDownList1.SelectedIndex == 0)
{
SqlDataAdapter da = new SqlDataAdapter("select * from Biscuits",con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
}
else if(DropDownList1.SelectedIndex == 1)
{
SqlDataAdapter da = new SqlDataAdapter("select * from oil", con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
}
when i am running the code it is giving error as
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.