473,406 Members | 2,954 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,406 software developers and data experts.

Datalist Problem

Well, suppose i have couple of controls in datalist and one of them is link
button control

how do i invoke link button controls click method in the datalist ???

Suppose link button control will send info back to server and redirect to
another page, how do i do it in datalist ?

I have following code in item templatae
<asp:LinkButton id="Linkbutton1" OnClick="OnClickMethod"
runat="server">Download Chapter</asp:LinkButton>
I want to be able to pass arguement to OnClickMethod [the arguement is
employee_id which comes from the table]

Something like when link button is clicked, it'll redirect to another page
containing employee details.

Nov 19 '05 #1
2 1447
In your ItemTemplate make the LinkButton have a CommandName="DoSomething".
On your Datalist specify the primary key for the rows via the DataKeyField="employee_id"
attribute. Then handle the DataList's ItemCommand event to do something like
this:

protected void _dataList_ItemCommand(object source, DataListCommandEventArgs
e)
{
if (e.CommandName == "DoSomething")
{
int employee_id = (int)_dataList.DataKeys[e.Item.ItemIndex];
// now do something with
}
}

But if your going to do all of this simply for a redirect, then it's much
simpler to just emit a hyperlink to the browser in the first place. This
also can be accomplished in your ItemTempate:

<asp:HyperLink runat="server" Text="Something"
NavigateUrl='OtherPage.aspx?EmpID=<%# DataBinder.Eval(Container.DataItem,
"employee_id") %>'></asp:HyperLink>

-Brock
DevelopMentor
http://staff.develop.com/ballen
Well, suppose i have couple of controls in datalist and one of them is
link button control

how do i invoke link button controls click method in the datalist ???

Suppose link button control will send info back to server and redirect
to another page, how do i do it in datalist ?

I have following code in item templatae
<asp:LinkButton id="Linkbutton1" OnClick="OnClickMethod"
runat="server">Download Chapter</asp:LinkButton>
I want to be able to pass arguement to OnClickMethod [the arguement is
employee_id which comes from the table]

Something like when link button is clicked, it'll redirect to another
page containing employee details.


Nov 19 '05 #2
Thanks
"Brock Allen" <ba****@develop.com.i_hate_spam_too> wrote in message
news:78*********************@msnews.microsoft.com. ..
In your ItemTemplate make the LinkButton have a CommandName="DoSomething".
On your Datalist specify the primary key for the rows via the
DataKeyField="employee_id" attribute. Then handle the DataList's
ItemCommand event to do something like this:

protected void _dataList_ItemCommand(object source,
DataListCommandEventArgs e)
{
if (e.CommandName == "DoSomething")
{
int employee_id = (int)_dataList.DataKeys[e.Item.ItemIndex];
// now do something with }
}

But if your going to do all of this simply for a redirect, then it's much
simpler to just emit a hyperlink to the browser in the first place. This
also can be accomplished in your ItemTempate:

<asp:HyperLink runat="server" Text="Something"
NavigateUrl='OtherPage.aspx?EmpID=<%# DataBinder.Eval(Container.DataItem,
"employee_id") %>'></asp:HyperLink>

-Brock
DevelopMentor
http://staff.develop.com/ballen
Well, suppose i have couple of controls in datalist and one of them is
link button control

how do i invoke link button controls click method in the datalist ???

Suppose link button control will send info back to server and redirect
to another page, how do i do it in datalist ?

I have following code in item templatae
<asp:LinkButton id="Linkbutton1" OnClick="OnClickMethod"
runat="server">Download Chapter</asp:LinkButton>
I want to be able to pass arguement to OnClickMethod [the arguement is
employee_id which comes from the table]

Something like when link button is clicked, it'll redirect to another
page containing employee details.


Nov 19 '05 #3

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

Similar topics

2
by: Antonio D'Ottavio | last post by:
Good Morning, In my web page I've a datalist that is sourced by a database, the problem is that I want that one of the column of the datalist contain a dropdownbox that also is sourced by a table...
4
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
1
by: Glenn Owens | last post by:
Here's the scenario: I have a DataList populated from a datatable sitting inside a fieldset. Each element (row) in the Datalist has the following child controls: asp:checkbox, asp:image,...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
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...
0
by: Les Caudle | last post by:
I have a menu system composed of a DataList nested inside a DataList. The outer DataList has it's DataSource (composed of a DataSet with two tables linked by a CategoryPagesRelation Relation) set...
2
by: scottls | last post by:
Hi All, Thanks for reading my post. I have been working on getting nested datalists working properly wihtin my framework for many days and I think I'm almost there. See if you could help me...
1
by: Jim in Arizona | last post by:
I'm don't know how I would get around this. When working with a datalist control, there a specific built in commands (OnEditCommand, OnCancelCommand, etc). These commands, when the datalist...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.