473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2709
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.