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

ItemDataBound event of DataGrid

Hello.
How can I field value in ItemDataBound event of the DataGrid control?
I'm writing:
e.Item.Cells[0].Text;

But this always returns empty string:(

Thank You.
Nov 18 '05 #1
2 1866
Consider doing e.Item.FindControl("controlId")

like

TextBox txt = (TextBox) e.Item.FindControl("userName");
if (txt != null){
//found it
}

it's less performant but 100% more readable and won't change when you alter
your html code....also, in case ur wondering, [0] is probably blank 'cuz I
believe whitespaces are converted to literals...which makes the [0] method
even more unreliable.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Dave" <da*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello.
How can I field value in ItemDataBound event of the DataGrid control?
I'm writing:
e.Item.Cells[0].Text;

But this always returns empty string:(

Thank You.

Nov 18 '05 #2
Karl is pointing you in the right direction. If you want some more
information on FindControl, I have an article here:
http://odetocode.com/Articles/116.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Thu, 7 Oct 2004 09:31:58 +0400, "Dave" <da*********@hotmail.com>
wrote:
Hello.
How can I field value in ItemDataBound event of the DataGrid control?
I'm writing:
e.Item.Cells[0].Text;

But this always returns empty string:(

Thank You.


Nov 18 '05 #3

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

Similar topics

1
by: TB | last post by:
Relatively new to .NET so please bear with me... I'm making an ASP.NET web application and am using VB to code. I'll try to set the stage here... The class and property names are generic to make...
1
by: Phil Townsend | last post by:
I am using the ItemDataBound event of a Datagrid to color code table cells according to data returned from a SQL stored procedure. At first everything worked, but then I decided to customize the...
3
by: Clouds | last post by:
Hi ! How do I add the dynamic event handler for a dropdownlist present in the itemtemplate of a datalist !! I am doing it in the itemdatabound event of the datalist but it doesnt work... I am...
1
by: Roy | last post by:
Hey all, This is a fairly broad question, but why is it that my datagrid hits the ItemDataBound event 3 times? Basically, I placed a response.write in all sub and functions in my codebehind and...
4
by: Girish | last post by:
Im trying to create a grid within a grid programmatically. Ive been successful in doing this but I need the embedded grid to fire its ItemDataBound event so I can handle it. The event does not seem...
1
by: needin4mation | last post by:
Hi, I have a datalist. In this datalist I have a datagrid. The datalist is the master. The datagrid is the detail. It works fine. I populate the datagrid inside of the datalist using the...
3
by: Jon | last post by:
Hello everyone, We're using ASP.net 1.1 and when we load a control dynamically, using LoadControl, the ItemDataBound of the DataGrid that sits in this dynamically loaded control does not get...
1
by: greenb | last post by:
I'm using the ItemDataBound event of the DataGrid to highlight cells that are outside an acceptable range. Each row has a button column (CommandName='Select'), that is used to display addtional...
1
by: GaryDean | last post by:
It seems every time I try to use the GridView to do what I used to do with the DataGrid I run into differences that make me want to got back to the datagrid. for instance... the DataGrid...
4
by: GaryDean | last post by:
I'm up against something else I used to easily do in a DataGrid that is different in a GridView.... I used to access cells in non-visible columns in the ItemDataBound event. The data was there -...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.