DataGridView Question

Discussion in 'ASP .Net' started by S Chapman, Jul 25, 2007.

  1. S Chapman

    S Chapman Guest

    I have a DataGridView on my page that uses Template Fields for some of
    the cells. One such cell has a DropDownList as a control on the
    EditItemTemplate. The user using a button on the page can add items to
    this drop down. I am unable to get a reference to this drop down list
    on the "template" so that I can add the new item to the list.


    I am able to however get a reference to specific row-wise instances of
    the DropDownList using:

    _grdMain.Rows[nIndex].FindControl("_cmbList")

    Do I have to add items to these individual controls or is it possible
    to obtain a reference to the template control itself and add the item
    only once? Thanks.
     
    S Chapman, Jul 25, 2007
    #1
    1. Advertising

  2. "S Chapman" <> wrote in message
    news:...

    >I have a DataGridView on my page


    Do you mean a DataGrid or a GridView...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 25, 2007
    #2
    1. Advertising

  3. S Chapman

    S Chapman Guest

    Sorry I meant {System.Web.UI.WebControls.GridView}
     
    S Chapman, Jul 25, 2007
    #3
  4. In theory, you can use LoadTemplate method to operate on templates in run
    time. Google for it for more info. I just think it will be much easier to
    add items to the ddl in every row.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "S Chapman" <> wrote in message
    news:...
    >I have a DataGridView on my page that uses Template Fields for some of
    > the cells. One such cell has a DropDownList as a control on the
    > EditItemTemplate. The user using a button on the page can add items to
    > this drop down. I am unable to get a reference to this drop down list
    > on the "template" so that I can add the new item to the list.
    >
    >
    > I am able to however get a reference to specific row-wise instances of
    > the DropDownList using:
    >
    > _grdMain.Rows[nIndex].FindControl("_cmbList")
    >
    > Do I have to add items to these individual controls or is it possible
    > to obtain a reference to the template control itself and add the item
    > only once? Thanks.
    >
     
    Eliyahu Goldin, Jul 25, 2007
    #4
  5. S Chapman

    Mridul Guest

    I think instead of trying to add item to DropDownList, you can add
    item to data source of DropDownList.
    This step will automatically add item to DropDownList and you don't
    need any reference of DropDownList.

    Thanks!
     
    Mridul, Jul 25, 2007
    #5
    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. dbuchanan
    Replies:
    7
    Views:
    7,503
    jtsmith2
    May 23, 2006
  2. =?Utf-8?B?Rmlyb3o=?=

    Forms inheritance - datagridview

    =?Utf-8?B?Rmlyb3o=?=, Jan 6, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,461
    =?Utf-8?B?Rmlyb3o=?=
    Jan 6, 2006
  3. dbuchanan

    DataGridView Scrollbars missing

    dbuchanan, Jan 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    16,447
    goldberg
    Nov 18, 2008
  4. =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?=

    RE: DataGridView with databound combobox

    =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?=, Mar 16, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    11,325
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Apr 2, 2006
  5. hangar18
    Replies:
    0
    Views:
    10,393
    hangar18
    Mar 27, 2006
Loading...

Share This Page