473,854 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

access to datalist value

Hi

Anyone knows how to access to a value of a row in a datalist. Something like this in datagrid
Dim str = MyDataGrid.Cell (0).tex

I would like something like this
Dim str = DataBinder.Eval (MyDatalist.Ite ms(count).DataI tem, "customerId ")
but it doesn't work.
Nov 18 '05 #1
4 8309
Hi Jenn,
You can access the Datalist values of a row like this :
In the ItemDataBound event of the DataList,
if(e.Item.ItemT ype == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem){

object row_items=e.Ite m.DataItem;

// If you have a column called customerId,

object items = e.Item.DataItem ;

string str1=Convert.To String(DataBind er.Eval(row_ite ms,"customerId" ));

}

Additional info:

You can find the controls in thge ItemTemplate of your datalist :

In ItemDataBound event :

eg :
((LinkButton)e. Item.FindContro l("LinkB")).Com mandArgument=e. Item.ItemIndex. T
oString();

This will set the commandargument for the Linkbutton,
LinkB.

The above code is in C#.

You can easily convert it into VB.NET.Let me know if you have any
problems.

Hope this helps.

Marshal Antony

..NET Developer

http://www.dotnetmarshal.com



"jenn" <an*******@disc ussions.microso ft.com> wrote in message
news:C0******** *************** ***********@mic rosoft.com...
Hi,

Anyone knows how to access to a value of a row in a datalist. Something like this in datagrid: Dim str = MyDataGrid.Cell (0).text

I would like something like this:
Dim str = DataBinder.Eval (MyDatalist.Ite ms(count).DataI tem, "customerId ")
but it doesn't work.

Nov 18 '05 #2
Hi Marshal

Thanks for the reply, but I'm looking at accessing the datalist values from outside of the ItemDatabound event. So what I did was to loop through the datalist like this

dim i as int=
while i<Mydatalist.it ems.coun

dim str = MyDatalist.Item s(i).DataItem(" customerid") <-- this does not wor

end whil

In datagrid you can easily do that like this

Dim str = MyDataGrid.Item s(i).Cell(0).te x

Is there a way to do this with datalist

----- Marshal Antony wrote: ----

Hi Jenn
You can access the Datalist values of a row like this
In the ItemDataBound event of the DataList
if(e.Item.ItemT ype == ListItemType.It em || e.Item.ItemType =
ListItemType.Al ternatingItem)

object row_items=e.Ite m.DataItem

// If you have a column called customerId

object items = e.Item.DataItem

string str1=Convert.To String(DataBind er.Eval(row_ite ms,"customerId" ))

Additional info

You can find the controls in thge ItemTemplate of your datalist

In ItemDataBound event

eg
((LinkButton)e. Item.FindContro l("LinkB")).Com mandArgument=e. Item.ItemIndex.
oString()

This will set the commandargument for the Linkbutton
LinkB

The above code is in C#

You can easily convert it into VB.NET.Let me know if you have an
problems

Hope this helps

Marshal Anton

..NET Develope

http://www.dotnetmarshal.co



"jenn" <an*******@disc ussions.microso ft.com> wrote in messag
news:C0******** *************** ***********@mic rosoft.com..
Hi
Anyone knows how to access to a value of a row in a datalist. Somethin
like this in datagrid Dim str = MyDataGrid.Cell (0).tex
I would like something like this Dim str = DataBinder.Eval

but it doesn't work


Nov 18 '05 #3
Hi Jenn,
In DataList ItemTemplate used for how each item will be rendered.
For example,
<ItemTemplate >
Customer <%#
Convert.ToStrin g(DataBinder.Ev al(ContainerDat aItem,"customer id"))%>
<ItemTemplate >

You can access datalist values out side of Itemdatabound..
You can use DataKeys collection to retrieve
information from the datalist.
For example if you have a delete event handler,
Dim str1 As
String=DataList 1.DataKeys(e.It em.ItemIndex)

Here is a link on MSDN on DataList web server control.
http://msdn.microsoft.com/library/de...classtopic.asp

Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com


"jenn" <an*******@disc ussions.microso ft.com> wrote in message
news:E4******** *************** ***********@mic rosoft.com...
Hi Marshal,

Thanks for the reply, but I'm looking at accessing the datalist values from outside of the ItemDatabound event. So what I did was to loop through
the datalist like this:
dim i as int=0
while i<Mydatalist.it ems.count

dim str = MyDatalist.Item s(i).DataItem(" customerid") <-- this does not work
end while

In datagrid you can easily do that like this:

Dim str = MyDataGrid.Item s(i).Cell(0).te xt

Is there a way to do this with datalist?

----- Marshal Antony wrote: -----

Hi Jenn,
You can access the Datalist values of a row like this :
In the ItemDataBound event of the DataList,
if(e.Item.ItemT ype == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem){

object row_items=e.Ite m.DataItem;

// If you have a column called customerId,

object items = e.Item.DataItem ;

string str1=Convert.To String(DataBind er.Eval(row_ite ms,"customerId" ));
}

Additional info:

You can find the controls in thge ItemTemplate of your datalist :

In ItemDataBound event :

eg :
((LinkButton)e. Item.FindContro l("LinkB")).Com mandArgument=e. Item.ItemIndex. T oString();

This will set the commandargument for the Linkbutton, LinkB.

The above code is in C#.

You can easily convert it into VB.NET.Let me know if you have any
problems.

Hope this helps.

Marshal Antony

..NET Developer

http://www.dotnetmarshal.com



"jenn" <an*******@disc ussions.microso ft.com> wrote in message
news:C0******** *************** ***********@mic rosoft.com...
> Hi,
>> Anyone knows how to access to a value of a row in a datalist.
Something like this in datagrid:
> Dim str = MyDataGrid.Cell (0).text
>> I would like something like this:

> Dim str = DataBinder.Eval (

> but it doesn't work.


Nov 18 '05 #4
I see. I'll try to use DataKeys then. Thanks for your help, Marshal.
Nov 18 '05 #5

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

Similar topics

0
1615
by: Celine | last post by:
I'm using a datalist to display a picture and a dropdownlist associated to it. When clicked the picture should display a larger picture ( this is working fine). When the user has selected a picture he has to select a value from the dropdownlist which corresponds to diferent sizes for the picture. My question is: how can I get the value of the dropdownlist? Please, I really need some help. Thanks
0
1731
by: Renato Neves | last post by:
My problem is simple, i have a datalist control with some controls inside of EditTemplate (the problem is the same in the DataGrid). I want to have access to this controls, using javascript, but i can't. How can i do this? <Code> <script language="javascript"> document.getElementById('<%=txt1.ClientID %>').value='test'; document.getElementById('<%=txt2.ClientID %>').value='test';
2
8740
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the DataList exposes and the result is always null (I've determined the OnItemDataBound event will not find the footer controls). I understand that I have to navigate the datalist object tree, but I feel like it is a guessing game and am hesitant to do it...
1
1810
by: zino | last post by:
is there a way to access an HTML control embeded inside a datalist ? I need to format the datalist depends on specific condition while databinding ( on ItemDataBound) <datalist runat=server> <itemTemplate> <input type=text value='<%# CType(Container.DataItem,System.Data.DataRowView)("myValue") %>' id=myControl> </itemTemplate> </datalist>
3
3127
by: webserverpete | last post by:
I am new to ASP.NET in general, but I do have experience with classic ASP. I am using a DataList control with a hidden value to submit to a different page, however I do not know how to get to that hidden value. Here is my DataList control code: <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="4"> <ItemTemplate> <%#DataBinder.Eval(Container.DataItem, "itemname")%> <br>...
1
11960
by: Gary Frank | last post by:
I added a couple of labels and a button to a Datalist control called "dlSignIn" by adding them to the Item template. The labels are bound to a dataset column. Program code gets executed in the dlSignIn_SelectedIndexChanged subroutine when I click the button in the datalist. And the dlSignIn.SelectedIndex property has the correct index for the Datalist row that was selected. Now I would like to access the values in the labels of that...
6
9600
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 only print the Parent Category once, regardless of how many child items are in it. So my perfect output would look something like:
4
2751
by: matt | last post by:
hello, i have a datagrid w/ a TemplateColumn in it, like so: <asp:TemplateColumn HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="chkSelected" Runat="server"/> </ItemTemplate> </asp:TemplateColumn>
1
2666
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 ID="dlTwo" DataKeyField="myField2" DataSource="<%# GetDataSource2(?,?)" Runat="server">
0
9901
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9751
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11024
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10675
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10749
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10367
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9512
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7912
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7079
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...

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.