79439532

Date: 2025-02-14 13:34:45
Score: 0.5
Natty:
Report link

I have removed the Gridview databind instruction from the Page_Load() event and only refresh it when required. It solved the problem. I can see why refreshing the values might mess up with the DataKeys, but I still wonder why it works in localhost !

// don't call this sub in the Page_Load() event
    
private void RefreshGridview()
{
    this.SqlDataSource_Contracts.SelectCommand = GetGridviewSql();
    this.GridView_Contracts.DataBind();
    Label_Gridview.Text = GridView_Contracts.Rows.Count + " contracts in the database";
}        
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Cookie Monster