I have an existing app (written by a previous developer) that is calling a stored procedure that populates a RadGrid control. It populates fine the first time around.
However, when I change the date parameter, click "search" button, I get a blank RadGrid control. When I click search the second time, the grid is populated. When I walk through the code, I get an error message
Column 'ID' does not belong to table Table.
How can I resolve the issue of having to click search twice to display data ?
protected void btnSubmit_OnClick(object sender, EventArgs e){ try { ViewState["newset"] = null; CreateDatasource(); this.RadGrid1.DataBind(); this.RadGrid1.CurrentPageIndex = 0; ViewState["newset"] = "new"; string idex = this.hdnindex.Value; if (idex != string.Empty) this.RadGrid1.MasterTableView.Items[int.Parse(idex)].Selected = true; } catch (Exception ex) { this.lblMessage.Text = ex.Message; } }protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e){ try { if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; HyperLink hLink = (HyperLink)item["ViewHyperLink"].Controls[0]; if (hLink != null) hLink.Attributes.Add("onclick", "selectMe('" + item.ItemIndex + "');"); } } catch (Exception ex) { this.lblMessage.Text = ex.Message; }}In the code behind above, when this.RadGrid1.DataBind() is called, the code steps into `RadGrid1_ItemCreated` loops through the if statement a few times, them goes into the if statement, comes out of the function, and then the catch statement of btnSubmit is called, which displays the error message "Column ID does not belong to table Table".
Any ideas on how to resolve this?