mmedi005
asked on
How do you add an event handler to a control in a row within a GridView in Edit Mode?
How do you add an event handler to a control in a row within a GridView?
I have radiobuttons inside EditItemTemplate tags. I want to add a the event below to each radiobutton. I want the RadioButton to control the Panel within the same row.
thx
I have radiobuttons inside EditItemTemplate tags. I want to add a the event below to each radiobutton. I want the RadioButton to control the Panel within the same row.
thx
protected void uxAddRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
{
uxPanel.Visible = Convert.ToBoolean(uxAddRadioButtonList.SelectedValue);
}
set the SelectedIndexChange property of the RadioButtonList to "uxAddRadioButtonList_Sele ctedIndexC hanged"
sorry, the name of the property is
onSelectedIndexChange
(i forgot the "on")
onSelectedIndexChange
(i forgot the "on")
ASKER
Will the RadioButtonList pair up with the Panel in each row the GridView Control creates?
ASKER
Got an error:
Compiler Error Message: CS0103: The name 'uxAddRadioButtonList' does not exist in the current context
Any ideas?
Here is more of the code....
Compiler Error Message: CS0103: The name 'uxAddRadioButtonList' does not exist in the current context
Any ideas?
Here is more of the code....
protected void uxAddRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
{
uxPanel.Visible = Convert.ToBoolean(uxAddRadioButtonList.SelectedValue);
}
<asp:GridView ID="uxChecksGridView" runat="server"
HorizontalAlign="Left"
DataSourceID="uxChecksSqlDataSource"
DataKeyNames="ID, Address"
OnRowCancelingEdit="uxChecksGridView_RowCancelingEdit"
OnRowDataBound="uxChecksGridView_RowDataBound"
OnRowEditing="uxChecksGridView_RowEditing"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
....
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList ID="uxAddAddressRadioButtonList" runat="server"
RepeatDirection="Horizontal"
RepeatLayout="Flow"
AutoPostBack="true"
OnSelectedIndexChanged="uxAddRadioButtonList_SelectedIndexChanged">
<asp:ListItem Text="Yes |" Value="True" />
<asp:ListItem Text="No" Value="False" />
</asp:RadioButtonList>
<asp:Panel ID="uxPanel" runat="server"
Visible="false">
......
</asp:Panel>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
is this the right direction...
this compiles, but i think this is having trouble identifying the uxPanel I want to change. The sender object is the RadioButtonList, correct?
How do I find the uxPanel control within the row?
What control do I use to use FindControl within that row?
this compiles, but i think this is having trouble identifying the uxPanel I want to change. The sender object is the RadioButtonList, correct?
How do I find the uxPanel control within the row?
What control do I use to use FindControl within that row?
protected void uxAddRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
{
RadioButtonList r = (RadioButtonList)sender;
uxPanel.Visible = Convert.ToBoolean(r.SelectedValue);
}
ok, you are in the right direction.
you could try r.parent.fincontrol("uxPan el")
you could try r.parent.fincontrol("uxPan
ASKER
that worked..thank you
Why does r.Parent.FindControl("uxPa nel") work?
How is r considered the Parent in this situation?
Thanks again...
Why does r.Parent.FindControl("uxPa
How is r considered the Parent in this situation?
Thanks again...
No, r.parent is the parent of the object "r" so since the RadioButtonList and the panel are "beside" they are in the same "container". So you could access that container by calling the parent property of a control.
Glad I could help.
Glad I could help.