Hi all, I want to display all the data in gridview which i am inserting in runtime. For that i have written code but getting this error.
"Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition."
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
public void BindData()
{
string str = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
SqlConnection con = new SqlConnection(str);
SqlDataAdapter da = new SqlDataAdapter("select * from Items where ItemId='" + TxtItemId.Text + "'", con);
DataSet ds = new DataSet();
da.Fill(ds,"Items");
GridView1.DataSource = ds;
GridView1.DataBind();
}
Pls modify my code where is my mistake.
Thanks, Sumit