Autogeneratecolumns = true, and I want to edit

Discussion in 'ASP .Net Datagrid Control' started by Andy Sutorius, Jun 29, 2004.

  1. Can someone point me to an article on how to edit a datagrid when the grid
    is set to autogeneratecolumns?

    Each article I have come across has instructions when autogenerate is false
    and you have an item template with data containers.

    Thanks

    Andy
     
    Andy Sutorius, Jun 29, 2004
    #1
    1. Advertising

  2. Here is an example:
    In your aspx page declare Datagrid as follows:
    <asp:DataGrid id="Datagrid2" runat="server" CssClass="grid"
    AutoGenerateColumns="True"><Columns>
    <asp:EditCommandColumn EditText="Edit" CancelText="Cancel"
    UpdateText="Update" /></Columns>
    </asp:DataGrid>

    In code behind, you need to Bind your data source to the datagrid and on
    Edit ItemCommand you can say
    Private Sub Datagrid2_EditCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    Datagrid2.EditCommand
    Datagrid2.EditItemIndex = e.Item.ItemIndex
    BindGrid()
    End Sub

    Again on Datagrids Update command you can read the values of the columns and
    then save it into the DB

    Hope this helps

    Thanks,
    Sandeep


    "Andy Sutorius" <> wrote in message
    news:SZlEc.73116$...
    > Can someone point me to an article on how to edit a datagrid when the grid
    > is set to autogeneratecolumns?
    >
    > Each article I have come across has instructions when autogenerate is

    false
    > and you have an item template with data containers.
    >
    > Thanks
    >
    > Andy
    >
    >
     
    Sandeep Kayal, Jun 30, 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. David M. Weprin
    Replies:
    0
    Views:
    420
    David M. Weprin
    Oct 16, 2003
  2. Andy Sutorius
    Replies:
    2
    Views:
    2,152
    Sandeep Kayal
    Jun 30, 2004
  3. Sachin
    Replies:
    0
    Views:
    2,449
    Sachin
    Mar 5, 2006
  4. =?Utf-8?B?bmt3?=

    Format GridView with AutoGenerateColumns=true

    =?Utf-8?B?bmt3?=, Mar 8, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    1,837
    Pak Lui
    Mar 11, 2007
  5. bdb112
    Replies:
    45
    Views:
    1,354
    jazbees
    Apr 29, 2009
Loading...

Share This Page