S
Steve Myers
I have a datagrid with 2 columns that I want to interact when I'm in
Edit Mode. I've reproduced just the columns I want to interact below.
I can get into Edit mode for the selected row just Fine. What I want
to do is to have the user select an entry in the editschSchedulePeriod
template (options are "D" or "M"). Once the user selects this, I want
to execute a subroutine to populate the EditschPeriod edititemtemplate
dropdownlist. This dropdownlist will have differing values based on
the selection from the first control. Hence I don't want to populate
it until the user selects an entry from the first dropdownlist.
I've tried to add a routine called "PeriodChange" that would execute
when the OnSelectedIndexChanged event occurs. However, I'm not sure if
this is the correct approach or if there is a better way.
I'm having trouble with the logic to access the controls.
Wonder if someone could help get me started with the logic to access
this control and populate the second control here.
thanks!
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit">
<ItemStyle Wrap="False"></ItemStyle>
</asp:EditCommandColumn>
<asp:TemplateColumn SortExpression="SchedulePeriod"
HeaderText="SchedulePeriod">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Label runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "SchedulePeriod") %>'
ID="schSchedulePeriod" />
</ItemTemplate>
<EditItemTemplate>
<aspropDownList runat="server"
OnSelectedIndexChanged="PeriodChange" SelectedIndex='<%#
GetSchedulePeriodIndex(Container.DataItem("SchedulePeriod")) %>'
id="editschSchedulePeriod">
<asp:ListItem>D</asp:ListItem>
<asp:ListItem>M</asp:ListItem>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Period" HeaderText="Period">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Label runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Period") %>' ID="schPeriod" />
</ItemTemplate>
<EditItemTemplate>
<aspropDownList runat="server" SelectedIndex='<%#
GetPeriodIndex(Container.DataItem("Period")) %>'
id="EditschPeriod">
</aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
Public Sub PeriodChange(ByVal sender As Object, ByVal e As
System.EventArgs)
How do I reference control and set other control here?
End Sub
Edit Mode. I've reproduced just the columns I want to interact below.
I can get into Edit mode for the selected row just Fine. What I want
to do is to have the user select an entry in the editschSchedulePeriod
template (options are "D" or "M"). Once the user selects this, I want
to execute a subroutine to populate the EditschPeriod edititemtemplate
dropdownlist. This dropdownlist will have differing values based on
the selection from the first control. Hence I don't want to populate
it until the user selects an entry from the first dropdownlist.
I've tried to add a routine called "PeriodChange" that would execute
when the OnSelectedIndexChanged event occurs. However, I'm not sure if
this is the correct approach or if there is a better way.
I'm having trouble with the logic to access the controls.
Wonder if someone could help get me started with the logic to access
this control and populate the second control here.
thanks!
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit">
<ItemStyle Wrap="False"></ItemStyle>
</asp:EditCommandColumn>
<asp:TemplateColumn SortExpression="SchedulePeriod"
HeaderText="SchedulePeriod">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Label runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "SchedulePeriod") %>'
ID="schSchedulePeriod" />
</ItemTemplate>
<EditItemTemplate>
<aspropDownList runat="server"
OnSelectedIndexChanged="PeriodChange" SelectedIndex='<%#
GetSchedulePeriodIndex(Container.DataItem("SchedulePeriod")) %>'
id="editschSchedulePeriod">
<asp:ListItem>D</asp:ListItem>
<asp:ListItem>M</asp:ListItem>
</aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Period" HeaderText="Period">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Label runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Period") %>' ID="schPeriod" />
</ItemTemplate>
<EditItemTemplate>
<aspropDownList runat="server" SelectedIndex='<%#
GetPeriodIndex(Container.DataItem("Period")) %>'
id="EditschPeriod">
</aspropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
Public Sub PeriodChange(ByVal sender As Object, ByVal e As
System.EventArgs)
How do I reference control and set other control here?
End Sub