DataGrid : dynamic BoundColumn & OnUpdateCommand

Discussion in 'ASP .Net' started by =?Utf-8?B?S2FyaW5lIFByb290?=, Jan 27, 2004.

  1. Hello

    Today I had to build a DataGrid very dynamically

    <asp:datagrid id="dgTAB" Runat="server" AutoGenerateColumns="False" OnEditCommand="TAB_Edit" OnCancelCommand="TAB_Cancel" OnUpdateCommand="TAB_Update" OnDeleteCommand="TAB_Delete"><Columns><asp:ButtonColumn HeaderText="Delete" Text="Delete" CommandName="Delete" /><asp:EditCommandColumn HeaderText="Edit" EditText="Edit" CancelText="Cancel" UpdateText="Update" /></Columns></asp:datagrid

    This is quite a classical one. Then I add in the code behind
    BoundColumn col = new BoundColumn ()
    col.DataField = ...
    col.HeaderText = ...
    dgTAB.Columns.Add (col)

    I have some of these, I don't know how many without querying my database, which is why I did it that way in the first place

    I managed the Delete column very well with a DataKeyField, but I have problems with the Edit Column. By hitting 'Delete', my DataGrid line becomes a line of TextBox which is ok, but hitting 'Update' won't work as I can't access the textboxes' values. It seems that when I enter my TAB_Edit function, the Columns collection only has the two columns Delete & Edit, and not all the BoundColumns I added..

    Any suggestions ? Thank
    Karine
     
    =?Utf-8?B?S2FyaW5lIFByb290?=, Jan 27, 2004
    #1
    1. Advertising

  2. (error) DataGrid : dynamic BoundColumn & OnUpdateCommand

    (an error slipped through while writing the message...

    Hello

    Today I had to build a DataGrid very dynamically

    <asp:datagrid id="dgTAB" Runat="server" AutoGenerateColumns="False" OnEditCommand="TAB_Edit" OnCancelCommand="TAB_Cancel" OnUpdateCommand="TAB_Update" OnDeleteCommand="TAB_Delete"><Columns><asp:ButtonColumn HeaderText="Delete" Text="Delete" CommandName="Delete" /><asp:EditCommandColumn HeaderText="Edit" EditText="Edit" CancelText="Cancel" UpdateText="Update" /></Columns></asp:datagrid

    This is quite a classical one. Then I add in the code behind
    BoundColumn col = new BoundColumn ()
    col.DataField = ...
    col.HeaderText = ...
    dgTAB.Columns.Add (col)

    I have some of these, I don't know how many without querying my database, which is why I did it that way in the first place

    I managed the Delete column very well with a DataKeyField, but I have problems with the Edit Column. By hitting 'Edit' (and not 'Delete', my mistake in the first msg), my DataGrid line becomes a line of TextBox which is ok, but hitting 'Update' won't work as I can't access the textboxes' values. It seems that when I enter my TAB_Edit function, the Columns collection only has the two columns Delete & Edit, and not all the BoundColumns I added..

    Any suggestions ? Thank
    Karine
     
    =?Utf-8?B?S2FyaW5lIFByb290?=, Jan 27, 2004
    #2
    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. Jim in Arizona
    Replies:
    0
    Views:
    387
    Jim in Arizona
    Dec 28, 2006
  2. mesut
    Replies:
    0
    Views:
    606
    mesut
    Jun 29, 2007
  3. DC
    Replies:
    2
    Views:
    626
  4. Dan

    DataGrid: OnUpdateCommand - getting the updated values

    Dan, Aug 18, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    169
  5. Jim in Arizona

    datalist vbCrLf & OnEditCommand/OnUpdateCommand Event Procedures

    Jim in Arizona, Dec 29, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    661
    Jim in Arizona
    Dec 29, 2006
Loading...

Share This Page