I’ve got a gridview (asp.net) with a checkbox and a radiobuttonlist.
Above this gridview I have a button that allows the user to set all SELECTED items
in the gridview to a particular value. What I mean by selected is that checkbox that is inside the gridview is checked. This gridview is inside an updatepanel and I dont know if this is the reason I am having an issue but here is my issue.
The gridview as I said has a checkbox like so:
<ItemTemplate>
<asp:CheckBox ID="chkSelector" runat="server"
ToolTip="Select row?" />
</ItemTemplate>
And a radiobutton list like so:
<asp:RadioButtonList ToolTip="Please provide an answer to the method." AutoPostBack="true" RepeatDirection="Horizontal" ID="rbAnswer" runat="server" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.AnswerID")%>' OnSelectedIndexChanged="rbAnswer_SelectedIndexChanged">
<asp:ListItem Text="Yes" Value="Yes" style="color:green;"></asp:ListItem>
<asp:ListItem Text="No" Value="No" style="color:red;"></asp:ListItem>
<asp:ListItem Text="N/A" Value="N/A" style="color:gray;"></asp:ListItem>
<asp:ListItem Value="" Text="" style="display: none" />
</asp:RadioButtonList>
When you check the checkbox (you can select multiple checkbox (line items in the grid) and then click this button. The button does something to this effect:
foreach (GridViewRow Row in this.gvLineItems.Rows)
{
CheckBox cb = (CheckBox)Row.FindControl("chkSelector");
Label id = (Label)Row.FindControl("lblID");
if (cb != null && cb.Checked)
{
long lID = Convert.ToInt32(gvLineItems.DataKeys[Row.RowIndex].Value);
RadioButtonList rbl = (RadioButtonList)Row.FindControl("rbAnswer");
rbl.Items.FindByText("N/A").Selected = true;
}
}
That is it loops through all items in the gridview. If the item is checked (chkSelector = true) then it sets the radiobutton list answer to “N/A”. I debug the code and I can see the answer is set correctly but then when my method is done the User Interface doesnt show the result. Meaning the answer was never set to N/A. It just maintains its original state…
Does anyone know why this is happening? I am using an updatepanel around this so I am not sure if that is the reason
???
1 Answer