DataBinding: 'System.Data.DataRowView' does not contain a property with the name

后端 未结 4 1556
我在风中等你
我在风中等你 2020-12-11 01:40

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

4条回答
  •  暖寄归人
    2020-12-11 02:18

    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

提交回复
热议问题