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

Pass Parameter to DataList Datasource!

AJ
Hi all,

I am trying pass a value to the DataSource method in a DataList like below.
DataSource = <%# GetData(DataBinder.Eval(Container.DataItem, "ID"))%>"

I get an error with this code, and am wondering if someone can show me the
correct syntax.

I have asked this question before, but unfortunately i don't remember the
correct syntax.

I know i can acheive the desired result using code behind 'ItemDataBound',
but am prefering to do it in the aspx page itself..

All help appreciated.

<asp:DataList ID="dlTest"
DataKeyField = "ID"
DataSource = <%# GetData(DataBinder.Eval(Container.DataItem,
"ID"))%>">
<ItemTemplate><%# DataBinder.Eval(Container.DataItem,
"Name")%></ItemTemplate>
</asp:DataList>

Cheers,
Adam
Jul 24 '06 #1
1 2117
DataSource should be set to an on object containing data items. What is it
in your case?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"AJ" <AJ@discussions.microsoft.comwrote in message
news:3C**********************************@microsof t.com...
Hi all,

I am trying pass a value to the DataSource method in a DataList like
below.
DataSource = <%# GetData(DataBinder.Eval(Container.DataItem, "ID"))%>"

I get an error with this code, and am wondering if someone can show me the
correct syntax.

I have asked this question before, but unfortunately i don't remember the
correct syntax.

I know i can acheive the desired result using code behind 'ItemDataBound',
but am prefering to do it in the aspx page itself..

All help appreciated.

<asp:DataList ID="dlTest"
DataKeyField = "ID"
DataSource = <%# GetData(DataBinder.Eval(Container.DataItem,
"ID"))%>">
<ItemTemplate><%# DataBinder.Eval(Container.DataItem,
"Name")%></ItemTemplate>
</asp:DataList>

Cheers,
Adam

Jul 24 '06 #2

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

Similar topics

1
by: Dion Heskett | last post by:
How can I pass a Class as a parameter to in a method ? i.e. Private myMethod( string pram1, Classobject as pram2) { Classobject.DataSource = reader; Classobject.DataBind(); }
0
by: bryanp10 | last post by:
I have a DataList on my page which contains multiple DropDownLists. My page defaults to showing six rows in the DataList. I want the ability to dynamically add rows if needed. Right now I'm just...
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...
1
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to...
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...
1
by: AJ | last post by:
Hi all, With the following code in mind : <asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%# GetDataSource1()" Runat="server"> <ItemTemplate> Output Value Here! <asp:DataList...
0
by: rn5a | last post by:
An ASP.NET app retrieves 3 columns named Product, Category & Price from a SQL Server 2005 DB table & displays them in a DataList. The headers of these 3 columns in the DataList are Product,...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.