I am getting this weird error... the primary key in my database is \'DocumentID\' so I know that is not the issue. I am trying to get the select,edit & delete gridview b
1- First step you have to select the Documentid column in SELECT statement
SelectCommand="SELECT [DocumentID], [DocumentTitle], [DocumentBody] FROM [tblDocument]" />
2- You have to include it in datagridview COLUMN as you did:
3- If you are using Paging in datagridview AllowPaging="True" ,you have to SELECT also documentid on the event OnSelectedIndexChanged="GridView1_SelectedIndexChanged" to SELECT data in second and third page and so on:
Then on the event OnSelectedIndexChanged="GridView1_SelectedIndexChanged" :
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
DataTable dt = // your SELECT statement //
GridView1.DataSource = dt;
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
if you dont use this void then you will get same error when you click page 2