DataGrid - Unable to update with dynamic BoundColumns

Discussion in 'ASP .Net' started by Funbeat, Jun 26, 2003.

  1. Funbeat

    Funbeat Guest

    Hi everybody,

    A very strange problem with WebControls :

    A Datagrid in an ASp.net application;
    Bound with a dataset through ado.net;
    The updatable columns are dynamically created;
    When I try to update my DataGrid, I access the cols by means of
    e.Item.Cells.Count (OnUpdate event)
    and there :
    e.Item.Cells.Count is equals to 1 (only the static column is seen) !!


    tech info :
    ---------
    - W2K workstation sp3
    - Version Microsoft .NET Framework :1.1.4322.573; Version ASP.NET
    :1.1.4322.573


    I'm stuck with this for 2 days, and so desperate...
    Any idea ?
    Thanks in advance for replying.

    Jean-Louis PAUL

    -------------------------------------

    The BoundColumns are created with :
    ====================================

    // objDSet : a dataset previously obtained
    foreach (DataColumn dc in objDSet.Tables[0].Columns)
    {
    BoundColumn bc = new BoundColumn();
    bc.Initialize();
    bc.HeaderText = dc.ColumnName;
    bc.DataField = dc.ColumnName;
    this.DataGrid1.Columns.AddAt(1 + dc.Ordinal, bc);
    }
    this.DataGrid1.DataSource = objDSet;
    this.DataGrid1.DataBind();
    ....


    Then, I try to access the modified values with :
    ================================================

    private void OnUpdate(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    // !! Note : While I have 2 BoundColumns, numCols=1 (only the static
    colmun is seen) !!
    int numCols = e.Item.Cells.Count;

    for (int i=1; i<numCols; i++)
    {
    String colvalue =((TextBox)e.Item.Cells.Controls[0]).Text;
    ...
    }
    }

    When I created the BoundColumns with the property page, it's OK for
    reading
    ==========================================================================

    ???
     
    Funbeat, Jun 26, 2003
    #1
    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. ruca
    Replies:
    10
    Views:
    3,468
    Jose Marcenaro
    Feb 23, 2004
  2. =?Utf-8?B?Y2hhcmxpZXdlc3Q=?=

    Problem Soring DataGrid using BoundColumns

    =?Utf-8?B?Y2hhcmxpZXdlc3Q=?=, Mar 31, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    398
    =?Utf-8?B?Y2hhcmxpZXdlc3Q=?=
    Mar 31, 2005
  3. New Bee
    Replies:
    1
    Views:
    350
  4. New Bee
    Replies:
    0
    Views:
    401
    New Bee
    Sep 7, 2007
  5. ruca

    Format Data in BoundColumns of DataGrid

    ruca, Feb 20, 2004, in forum: ASP .Net Web Controls
    Replies:
    10
    Views:
    227
    Jose Marcenaro
    Feb 23, 2004
Loading...

Share This Page