Using controls in datagrid cells

E

et

How can I retrieve the Container.DataItem name in a checkbox used in a
template column. During an Update, I can dynamically retrieve the value of
the checkbox, but I need to retrieve the DataItem also.

<asp:TemplateColumn>
<ItemTemplate>
<asp:checkbox id="Checkbox7" runat="server" Checked='<%# fixnull(
DataBinder.Eval(Container.DataItem,"Paid") )%>'>
</asp:checkbox>
</ItemTemplate>
</asp:TemplateColumn>



CodeBehind during Update:
with e.Item
With .Cells(i)
If .HasControls() then
if typeof .Controls(1) is CheckBox then
Dim q as Boolean = cType(.Controls(1), CheckBox).checked
if q = False then
Values = 0
FieldName=?????????????
else
Values = 1
FieldName = ?????????????
End If
 
B

Brock Allen

You can iterate over your Control's parent controls until one implements
the interface IDataItemContainer. Once you have IDataItemContainer, just
access the IDataItemContainer.DataItem property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top