473,466 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I wire up a button in a datalist template?

using vb.net 1.1 I have a datalist and in it's item template I have 2
buttons, 'edit' and 'ShipToThisAddress'. The edit button works fine and it
opens up the edit template as it works with the edit command. But the how
do I wire ShipToThisAddress button? Its going to submit the address ID to
the database and do a redirect to another page. In the process of doing
this, it will need to get the row index in the datalist so I can get the
address ID from the datalist's keys collection.

Thanks.

--
mo*******@nospam.com
Nov 18 '05 #1
3 2712
OK I partially solved my problem, but I didn't answer my question. In
btnShipTo I used the item command by inputting 'item' in the command name
property for btnShipTo in the designer. Then in the codebehind I used the
following event to get the items key as a result of the button's the click
event and do something with it.

Private Sub dlAddresses_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs ) Handles
dlAddresses.ItemCommand
Dim key As String = dlAddresses.DataKeys.Item(e.Item.ItemIndex)
Console.WriteLine(key)
End Sub

HOWEVER

suppose this command was already being used for something like Selecting the
list item as the online documentation suggests. Then I would have to wire
up btnShipTo from scratch. How would I do that?

--
mo*******@nospam.com
"moondaddy" <mo*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
using vb.net 1.1 I have a datalist and in it's item template I have 2
buttons, 'edit' and 'ShipToThisAddress'. The edit button works fine and it opens up the edit template as it works with the edit command. But the how
do I wire ShipToThisAddress button? Its going to submit the address ID to
the database and do a redirect to another page. In the process of doing
this, it will need to get the row index in the datalist so I can get the
address ID from the datalist's keys collection.

Thanks.

--
mo*******@nospam.com

Nov 18 '05 #2
If you fill CommandName and CommandArgument of LinkButton you can use
ItemCommand event for handle event end get address ID for redirect!

In this way you can write code similar this :

[c# - CodeBehind]
private void DataList1_ItemCommand(object source, DataListCommandEventArgs
e)
{
if (e.CommandName.ToString() == "SkipTo")
{
string addressId = e.CommandArgument.ToString();
}
}

[ASP:NET]
<asp:DataList id="DataList1" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lbtSkip" Runat=server CommandName="SkipTo"
CommandArgument="<%# DataBinder.Eval(Container.DataItem, "AddressID")
%>"></asp:LinkButton>
</ItemTemplate>
</asp:DataList>

"moondaddy" <mo*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
using vb.net 1.1 I have a datalist and in it's item template I have 2
buttons, 'edit' and 'ShipToThisAddress'. The edit button works fine and it opens up the edit template as it works with the edit command. But the how
do I wire ShipToThisAddress button? Its going to submit the address ID to
the database and do a redirect to another page. In the process of doing
this, it will need to get the row index in the datalist so I can get the
address ID from the datalist's keys collection.

Thanks.

--
mo*******@nospam.com

Nov 18 '05 #3
Thanks that worked great. I didn't realize that you have multiple buttons
use the item command event. Then in the item command event use a select
case for the command argument to handle each button differently.

--
mo*******@nospam.com
"Bruno Sirianni" <br***********@virgilio.it> wrote in message
news:Lv*********************@news4.tin.it...
If you fill CommandName and CommandArgument of LinkButton you can use
ItemCommand event for handle event end get address ID for redirect!

In this way you can write code similar this :

[c# - CodeBehind]
private void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.ToString() == "SkipTo")
{
string addressId = e.CommandArgument.ToString();
}
}

[ASP:NET]
<asp:DataList id="DataList1" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lbtSkip" Runat=server CommandName="SkipTo"
CommandArgument="<%# DataBinder.Eval(Container.DataItem, "AddressID")
%>"></asp:LinkButton>
</ItemTemplate>
</asp:DataList>

"moondaddy" <mo*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
using vb.net 1.1 I have a datalist and in it's item template I have 2
buttons, 'edit' and 'ShipToThisAddress'. The edit button works fine and

it
opens up the edit template as it works with the edit command. But the how do I wire ShipToThisAddress button? Its going to submit the address ID to the database and do a redirect to another page. In the process of doing
this, it will need to get the row index in the datalist so I can get the
address ID from the datalist's keys collection.

Thanks.

--
mo*******@nospam.com


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: moondaddy | last post by:
I have a datalist that makes use of the edit template. In this template I also have client side validation controls for required fields. My problem is that when I click on the cancel button it...
3
by: moondaddy | last post by:
using vb.net 1.1 I have a datalist and in it's item template I have 2 buttons, 'edit' and 'ShipToThisAddress'. The edit button works fine and it opens up the edit template as it works with the...
3
by: pierre.basson | last post by:
Hi, I have a DataList with an Item Template that contains an image and three radio buttons, which are used to indicate the image's status. How can I set the appropriate radio button to checked,...
1
by: jagdishl | last post by:
Hi: I have a datalist which is populated dynamically based on a query.I have to place a submit button after datalist (not in the footer template) so that after pressing the submit button a final...
2
by: Jack | last post by:
Hello, I need to add extra buttons to a datalist, but I don't know to add them to the control. I need to use the onCommand Functions, like OnUpdate, OnEdit, OnUpdate, OnCanel, Etc. I would...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
16
by: Vikas Kumar | last post by:
i am selectin some data from database and through reader showing it in datalist as above now for radio buttons i have single column which returns 1,2,3 and according to that i want one of above...
2
by: rhyme2ri2 | last post by:
Hi!! I'm using asp.net 1.1 I have a datalist which gets dynamic data which is of unbound size may be small sometimes and may be very very long sometimes....... Whatever the size of data may be...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.