Hi
I have a footer row in a gridview that allows inserting of records into a table. One of the controls is a DropDownList control. I want this control to default to the value in the QueryString. So I have this code:
protected void Page_Load(objec t sender, EventArgs e)
{
DropDownList MenuInsert = gridviewPages.F ooterRow.FindCo ntrol("MenuInse rt") as DropDownList;
MenuInsert.Sele ctedValue = Server.UrlDecod e(Request.Query String["Menu"]);
}
This works FINE when the page first loads. But then, when I add or edit or delete a row, i.e. after postback, the default does NOT get set.
If I debug the code, at execution the code is picking up the correct control (checked the ClientID) and it runs the SelectedValue line, but when the page displays, it is not selected.
Why not? The QueryString is still valid. I have in fact tested this on a TextBox in the Footer row, and I can't get a default to persist after postback there either. Any ideas? Something to do with VIEWSTATE?
Thanks
I have a footer row in a gridview that allows inserting of records into a table. One of the controls is a DropDownList control. I want this control to default to the value in the QueryString. So I have this code:
protected void Page_Load(objec t sender, EventArgs e)
{
DropDownList MenuInsert = gridviewPages.F ooterRow.FindCo ntrol("MenuInse rt") as DropDownList;
MenuInsert.Sele ctedValue = Server.UrlDecod e(Request.Query String["Menu"]);
}
This works FINE when the page first loads. But then, when I add or edit or delete a row, i.e. after postback, the default does NOT get set.
If I debug the code, at execution the code is picking up the correct control (checked the ClientID) and it runs the SelectedValue line, but when the page displays, it is not selected.
Why not? The QueryString is still valid. I have in fact tested this on a TextBox in the Footer row, and I can't get a default to persist after postback there either. Any ideas? Something to do with VIEWSTATE?
Thanks
Comment