DataGrid + BoundColumn + UpdateCommand

Discussion in 'ASP .Net' started by niki, Jun 17, 2005.

  1. niki

    niki Guest

    Hello.
    I have a problem with custom columns inside the datagrid.
    I've set up a datagrid that populates from a database; I can edit the
    datagrid values and update the db, so that's ok.
    (btw, it's not as easy as the book claims...)

    Now I'd like to format some columns, say date values, and what's more,
    I'd like to make some columns not visible and some read-only.
    I thought BoundColumn could be the solution, but as I create columns
    this way and invoke the updatecommand event, the datagrid has no more
    columns.
    Inside the updatecommand event, the datagrid has just 1 column, I guess
    it's the button one...

    I've search this ng for some advice, but I couldn't understand how it
    can be done.

    Can you help me?

    Thanks :)
     
    niki, Jun 17, 2005
    #1
    1. Advertising

  2. Hi Niki,

    You can use BoundCloumns and set Visible, ReadOnly properties for the
    BoundCloumns like follows.:

    <asp:datagrid id="datagrid" runat="server">
    <Columns>
    <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
    CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
    <asp:BoundColumn Visible="False" DataField="ID" ></asp:BoundColumn>
    <asp:BoundColumn DataField="FieldName" ReadOnly="True" HeaderText="Filed
    Name"></asp:BoundColumn>
    <asp:BoundColumn DataField="Edid_FieldName" HeaderText="Filed
    Name"></asp:BoundColumn>
    ....

    </Columns>
    </asp:datagrid>

    Updatecommand event is trggered by clicking Update button. You can get data
    by e.Item.Cells[col_index].Text.

    HTH

    Elton Wang




    "niki" wrote:


    > Hello.
    > I have a problem with custom columns inside the datagrid.
    > I've set up a datagrid that populates from a database; I can edit the
    > datagrid values and update the db, so that's ok.
    > (btw, it's not as easy as the book claims...)
    >
    > Now I'd like to format some columns, say date values, and what's more,
    > I'd like to make some columns not visible and some read-only.
    > I thought BoundColumn could be the solution, but as I create columns
    > this way and invoke the updatecommand event, the datagrid has no more
    > columns.
    > Inside the updatecommand event, the datagrid has just 1 column, I guess
    > it's the button one...
    >
    > I've search this ng for some advice, but I couldn't understand how it
    > can be done.
    >
    > Can you help me?
    >
    > Thanks :)
    >
    >
     
    =?Utf-8?B?RWx0b24gVw==?=, Jun 17, 2005
    #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. dawn
    Replies:
    1
    Views:
    496
    Daniel Bass
    Jul 28, 2003
  2. Learning SQL Server
    Replies:
    2
    Views:
    2,521
    Learning SQL Server
    Aug 7, 2003
  3. mesut
    Replies:
    0
    Views:
    609
    mesut
    Jun 29, 2007
  4. srathin

    DataGrid1 UpdateCommand calling DataGrid2 UpdateCommand

    srathin, Apr 9, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    192
    srathin
    Apr 9, 2005
  5. srathin

    DataGrid1 UpdateCommand calling DataGrid2 UpdateCommand

    srathin, Apr 9, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    178
    srathin
    Apr 11, 2005
Loading...

Share This Page