controlling button in headertemplate datagrid

J

JoNa SuperGold

hey, i have put a button in the header template of my datagrid, now this
button has te purpose that when you check the checkboxes in the item
template and you click on the button, the selected data is shown more
exessive.

but im having trouble addressing my button
in the html code i find the id= x
but when i want to address x i have an error saying it is not declared

that aside...someone can tell me how to address the button?

i tried it with as imilar code like this but didnot work

<asp:ButtonColumn Text="Get Details" ButtonType="PushButton"
CommandName="GetDetails"></asp:ButtonColumn>
E.CommandName = "GetDetails"

tia
--
*****************************
*******JoNa SuperGold*******
*****************************
**The Apple That Has It All**
*****************************
 
J

Jeff

You have to give address a function to the onclick event during
datagrid Item created.

something like this
If EventArgs.Item.ItemType = ListItemType.Header Then
Dim btn As Button =
CType(EventArgs.Item.Cells(2).FindControl("Button1), Button)
AddHandler btn.Click, AddressOf buttonClickEvent

End If

So you will create your own Private sub buttonClickEvent and do what
you need to in there.

So you shouldn't have a buttoncolumn. You should have a Template column
and add a normal button to the HeaderTemplate soemthing like this.

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 104; LEFT: 480px;
POSITION: absolute; TOP: 232px" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="Blah" HeaderText="Blah"></asp:BoundColumn>
<asp:BoundColumn DataField="Blah2" HeaderText="Blah
2"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Button">
<HeaderTemplate>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</HeaderTemplate>
</asp:TemplateColumn>
</Columns>
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top