Autogeneratecolumns = true, and I want to edit

Discussion in 'ASP .Net' 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. Not unless you dynamically (in the code behind) add the Item Templates
    to your DataGird.

    Regards

    Trevor Benedict R
    MCSD

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Trevor Benedict R, Jun 30, 2004
    #2
    1. Advertising

  3. 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
    #3
    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. Sachin
    Replies:
    0
    Views:
    2,450
    Sachin
    Mar 5, 2006
  3. =?Utf-8?B?bmt3?=

    Format GridView with AutoGenerateColumns=true

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

    Autogeneratecolumns = true, and I want to edit

    Andy Sutorius, Jun 29, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    187
    Sandeep Kayal
    Jun 30, 2004
Loading...

Share This Page