How do I get to this control?

  • Thread starter Thread starter jm
  • Start date Start date
J

jm

I have a pushbutton in templatecolumn in a DataGrid. I can iterate
through some of the rows in the datagrid with:

sub alert_inactive(sender As Object, e As DataGridCommandEventArgs)
dim item as datagriditem

For Each item In sender.Items
response.write("<br>The answer is: <BR>" & item.Cells(1).Text & " " &
item.Cells(2).Text & " " & item.Cells(3).Text)
Next item
end sub

However, in the DataGrid there is this:

<asp:TemplateColumn HeaderText="Completed"
ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:button id="butCompleted" causesvalidation="false"
text="Completed?" commandname="Delete" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Completed"
ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:button id="butChecked" commandname="Delete"
causesvalidation="false" text="Checked?" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>

I cannot figure out how to get the ID of these two buttons in this
function.

Thank for any help.
 
To get at the fully qualified ID of your control (as you have observed,
ASP.NET decorates the ID to ensure uniqueness) you can use the UniqueID
property of a particular button control.
 
Chris Jackson said:
To get at the fully qualified ID of your control (as you have observed,
ASP.NET decorates the ID to ensure uniqueness) you can use the UniqueID
property of a particular button control.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert


I ended up with:

dim butName as String = e.CommandSource.CommandName

if butName = "Completed" then
....

Thanks.
 
Back
Top