ItemDataBound event of DataGrid

Discussion in 'ASP .Net' started by Dave, Oct 7, 2004.

  1. Dave

    Dave Guest

    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.
    Dave, Oct 7, 2004
    #1
    1. Advertising

  2. Dave

    Karl Seguin Guest

    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" <> wrote in message
    news:%...
    > 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.
    >
    >
    Karl Seguin, Oct 7, 2004
    #2
    1. Advertising

  3. Dave

    Scott Allen Guest

    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" <>
    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.
    >
    Scott Allen, Oct 7, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattB
    Replies:
    4
    Views:
    21,213
  2. =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=

    Datagrid ItemDatabound event ??

    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Nov 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,070
    Eliyahu Goldin
    Nov 21, 2005
  3. Replies:
    1
    Views:
    956
    =?Utf-8?B?RWx0b24gVw==?=
    Jan 25, 2006
  4. GaryDean
    Replies:
    1
    Views:
    8,670
    Walter Wang [MSFT]
    Aug 18, 2006
  5. NH
    Replies:
    2
    Views:
    511
    Andrew L. Van Slaars
    Dec 17, 2004
Loading...

Share This Page