Is it possible to get a control by ID like e.Item.Cells[1].Controls["toto"]

Discussion in 'ASP .Net Datagrid Control' started by SoftLion, May 6, 2004.

  1. SoftLion

    SoftLion Guest

    Is it possible to get a control by ID like that :

    void DataGrid1_ValidateEdit(object sender, DataGridCommandEventArgs e)
    {
    object obj = e.Item.Cells[2].Controls["myControlID"];
    instead of:
    object obj = e.Item.Cells[2].Controls[0];
    }

    Or is there a way to do this easily ?
     
    SoftLion, May 6, 2004
    #1
    1. Advertising

  2. SoftLion

    SoftLion Guest

    Ok I found the solution,
    FindControl ....
     
    SoftLion, May 6, 2004
    #2
    1. Advertising

  3. SoftLion

    George Guest

    Well,

    i have never done it that way but I know this way works:

    dim workDropDownList as dropdownlist

    workDropDownList = CType(e.Item.FindControl("ddlDivision"),
    DropDownList)




    the point being the FindControl function will return a reference to
    the control with the ID specified.

    I hope this helps.
    George
     
    George, May 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. Joel Finkel

    Cells[].Text or Cells[].Controls[0]

    Joel Finkel, Sep 1, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    311
    Joel Finkel
    Sep 1, 2003
  2. Ravichandran Mahalingam

    (TextBox) (e.Item.Cells[2].Controls[0]) - Cast Invalid - Cannot update.

    Ravichandran Mahalingam, Jan 12, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    188
    Ravichandran Mahalingam
    Jan 12, 2004
  3. Keith-Earl
    Replies:
    5
    Views:
    182
  4. cognominal
    Replies:
    1
    Views:
    116
    Thomas 'PointedEars' Lahn
    Apr 20, 2006
  5. Une Bévue

    meaning of (toto)? true : false

    Une Bévue, Oct 29, 2011, in forum: Javascript
    Replies:
    6
    Views:
    642
    Thomas 'PointedEars' Lahn
    Oct 30, 2011
Loading...

Share This Page