How can I get textbox created ID in itemdatabound

Discussion in 'ASP .Net Datagrid Control' started by Ather Ali Shaikh, Sep 4, 2004.

  1. IHi All,

    I have a Master grid under this master grid i have child grid in template column. FINE.

    but int this child grid i have text box and buttons hard coded. When I bound the grid with datasource it binds. FINE.

    On the time binding I add attribute to button to run javascript.

    As

    mytxtControl = CType(e.Item.FindControl("txtDate"), TextBox )
    CType(e.Item.FindControl("btnGet"), Button ).Attributes("onclick","return ImageList(' " & mytxtControl.ID & " ')")
    this returns
    mytxtControl.ID = nothing
    and in view source of html it shows: DGTestMaster:_ctl2:DGTestDetail:_ctl3:txtDate

    I want to pass mytxtControl.ID to popup list against this textboxID

    How can I do this.

    Regards
    Ather Ali Shaikh
     
    Ather Ali Shaikh, Sep 4, 2004
    #1
    1. Advertising

  2. Ather Ali Shaikh

    Teemu Keiski Guest

    Did you try mytxtControl.ClientID ?

    ClientID is the ID that is rendered to the client-side ID attribute and it
    is client-script friendly.

    If in this case even ClientID doesn't work, try either setting the ID
    explicitly in the declarative syntax for the TextBox, if you haven't done
    so. If you have already done that, move the code to DataGrid_PreRender, loop
    through DataGrid's Items and get the TextBox from each of them (at this
    point they have IDs for sure).

    If this doesn't seem to help, post the declarative syntax and code for us to
    check.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke


    "Ather Ali Shaikh" <> wrote in message
    news:%...
    IHi All,

    I have a Master grid under this master grid i have child grid in template
    column. FINE.

    but int this child grid i have text box and buttons hard coded. When I bound
    the grid with datasource it binds. FINE.

    On the time binding I add attribute to button to run javascript.

    As

    mytxtControl = CType(e.Item.FindControl("txtDate"), TextBox )
    CType(e.Item.FindControl("btnGet"), Button ).Attributes("onclick","return
    ImageList(' " & mytxtControl.ID & " ')")
    this returns
    mytxtControl.ID = nothing
    and in view source of html it shows:
    DGTestMaster:_ctl2:DGTestDetail:_ctl3:txtDate

    I want to pass mytxtControl.ID to popup list against this textboxID

    How can I do this.

    Regards
    Ather Ali Shaikh
     
    Teemu Keiski, Sep 5, 2004
    #2
    1. Advertising

  3. Thank you,
    ClientID is working fine.

    Regards
    Ather Ali Shaikh

    "Teemu Keiski" <> wrote in message
    news:%...
    > Did you try mytxtControl.ClientID ?
    >
    > ClientID is the ID that is rendered to the client-side ID attribute and it
    > is client-script friendly.
    >
    > If in this case even ClientID doesn't work, try either setting the ID
    > explicitly in the declarative syntax for the TextBox, if you haven't done
    > so. If you have already done that, move the code to DataGrid_PreRender,

    loop
    > through DataGrid's Items and get the TextBox from each of them (at this
    > point they have IDs for sure).
    >
    > If this doesn't seem to help, post the declarative syntax and code for us

    to
    > check.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    > http://blogs.aspadvice.com/joteke
    >
    >
    > "Ather Ali Shaikh" <> wrote in message
    > news:%...
    > IHi All,
    >
    > I have a Master grid under this master grid i have child grid in template
    > column. FINE.
    >
    > but int this child grid i have text box and buttons hard coded. When I

    bound
    > the grid with datasource it binds. FINE.
    >
    > On the time binding I add attribute to button to run javascript.
    >
    > As
    >
    > mytxtControl = CType(e.Item.FindControl("txtDate"), TextBox )
    > CType(e.Item.FindControl("btnGet"), Button ).Attributes("onclick","return
    > ImageList(' " & mytxtControl.ID & " ')")
    > this returns
    > mytxtControl.ID = nothing
    > and in view source of html it shows:
    > DGTestMaster:_ctl2:DGTestDetail:_ctl3:txtDate
    >
    > I want to pass mytxtControl.ID to popup list against this textboxID
    >
    > How can I do this.
    >
    > Regards
    > Ather Ali Shaikh
    >
    >
     
    Ather Ali Shaikh, Sep 6, 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. Raed Sawalha
    Replies:
    2
    Views:
    1,554
    =?Utf-8?B?UHN5Y2hv?=
    Oct 5, 2004
  2. =?Utf-8?B?bXdoYWxlbg==?=

    Can't edit dynamically created textbox

    =?Utf-8?B?bXdoYWxlbg==?=, Jan 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    500
    MWells
    Jan 29, 2005
  3. JaM
    Replies:
    2
    Views:
    3,014
  4. Jay

    DataGrid write to Textbox in ItemDataBound help.

    Jay, Jul 29, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    231
  5. xzzy

    how to get value of datarow column on ItemDataBound

    xzzy, Jun 18, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    399
    Bhuva
    Jun 19, 2006
Loading...

Share This Page