Hello Gene,
Thanks for posting in the group.
Based on my understand, now the question is: In your datagrid, there are
two controls in an EditItem Template. Is there any way for a method in code
behind file to access these type of controls? Please feel free to post here
if I have any misunderstandings.
Generally speaking, we could use the FindControl method to create a
reference to the control, whenever we know the ID of the control whose
value we want.
The following example shows the HTML syntax for a template column that
displays Boolean data. Both the ItemTemplate and EditItemTemplate use a
check box to display the value. In the ItemTemplate, the check box is
disabled so that users do not think they can check it. In the
EditItemTemplate, the check box is enabled.
<Columns>
<asp:TemplateColumn HeaderText="Discontinued">
<ItemTemplate>
<asp:Checkbox runat="server" enabled= false name ="Checkbox2"
ID="Checkbox2"
Checked = '<%# DataBinder.Eval(Container,
"DataItem.Discontinued") %>' >
</asp:Checkbox>
</ItemTemplate>
<EditItemTemplate>
<asp:Checkbox
runat="server" name ="Checkbox2" ID="Checkbox2"
Checked = '<%# DataBinder.Eval(Container,
"DataItem.Discontinued") %>' >
</asp:Checkbox>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
// C#
CheckBox cb;
cb = (CheckBox) e.Item.FindControl("CheckBox2");
In Visual Studio, you can use the grid's Property builder to create the
template column and use the template editor to specify the layout. In the
Columns tab of the Properties window page for the grid, select the column
and at the bottom, click Convert this column into a Template Column. Close
the Properties window, right-click the grid, and choose Edit Template. You
can then drag controls from the Toolbox into the template and add static
text.
Does that answer your question?
Best regards,
Yanhong Huang
Microsoft Online Partner Support
Get Secure! ¨C
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.