Datagrid columns

D

Darin

I posted this question in the ASP.NET newsgroup not
knowing about this newsgroup.

I need to create a column with 4 links in that column
that take 4 different actions against that row when
clicked.

I do not see how to add 4 links under one column using
the datagrid's property builder.

Can anyone give me any direction or links to articles?

Thanks.
..
 
O

Oliver

Hi Darin,

You want to create a template column, put your button items in it and set the
CommandName property for each. Then in your code, you catch the ItemCommand
event and evaluate which object cause the event. The .aspx stuff is first
below, then the event handler code.

<columns>
<asp:templatecolumn>
<itemtemplate>
<p>
<asp:linkbutton id="LinkButton1" runat="server"
causesvalidation="false" commandname="Navigate"
text="MultiAction" tooltip="Goes elsewhere">Navigate
Away</asp:linkbutton></p>
<p>
<asp:button id="Button1" runat="server" commandname="ShowTime"
text="Show Time"></asp:button></p>
<p>
<asp:imagebutton id="ImageButton1" runat="server"
commandname="MakeRed"
imageurl="http://www.gc.ca/images/flag.gif"></asp:imagebutton></p>
<p>
<asp:linkbutton id="LinkButton2" runat="server"
commandname="Update" borderstyle="Solid"
bordercolor="#FFFFC0">Update</asp:linkbutton></p>
</itemtemplate>
</asp:templatecolumn>
<asp:boundcolumn datafield="UnitPrice"
dataformatstring="{0:C}"></asp:boundcolumn>
</columns>


Private Sub DataGrid1_ItemCommand _
(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
Handles DataGrid1.ItemCommand
Select Case e.CommandName
Case "Navigate"
Response.Redirect("http://www.aspalliance.com/kenc")
Case "ShowTime"
Label1.Text = Now.ToLongTimeString
Case "Update"
Response.Write("<script>alert('This would update')</script>")

Case "MakeRed"
e.Item.BackColor = Color.Red
End Select
End Sub

I posted this question in the ASP.NET newsgroup not
knowing about this newsgroup.

I need to create a column with 4 links in that column
that take 4 different actions against that row when
clicked.

I do not see how to add 4 links under one column using
the datagrid's property builder.

Can anyone give me any direction or links to articles?

Thanks.
..
 
D

darin

Thanks Oliver!

-----Original Message-----
Hi Darin,

You want to create a template column, put your button items in it and set the
CommandName property for each. Then in your code, you catch the ItemCommand
event and evaluate which object cause the event. The .aspx stuff is first
below, then the event handler code.

<columns>
<asp:templatecolumn>
<itemtemplate>
<p>
<asp:linkbutton id="LinkButton1" runat="server"
causesvalidation="false" commandname="Navigate"
text="MultiAction" tooltip="Goes elsewhere">Navigate
Away</asp:linkbutton></p>
<p>
<asp:button id="Button1" runat="server" commandname="ShowTime"
text="Show Time"></asp:button></p>
<p>
<asp:imagebutton id="ImageButton1" runat="server"
commandname="MakeRed"
imageurl="http://www.gc.ca/images/flag.gif"></asp:imagebu
tton> said:
<p>
<asp:linkbutton id="LinkButton2" runat="server"
commandname="Update" borderstyle="Solid"
bordercolor="#FFFFC0">Update</asp:linkbutton></p>
</itemtemplate>
</asp:templatecolumn>
<asp:boundcolumn datafield="UnitPrice"
dataformatstring="{0:C}"></asp:boundcolumn>
</columns>


Private Sub DataGrid1_ItemCommand _
(ByVal source As Object, _
ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) _
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top