How do I get to this control?

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.
 
C

Chris Jackson

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.
 
J

jm

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.
 

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

Top