468,136 Members | 1,441 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,136 developers. It's quick & easy.

Autogeneratecolumns = true, and I want to edit

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
Nov 18 '05 #1
2 2060
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!
Nov 18 '05 #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" <an**@sutorius.com> wrote in message
news:SZ*********************@twister.southeast.rr. com...
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

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Frank | last post: by
reply views Thread by swnshp | last post: by
5 posts views Thread by Jibey Jacob | last post: by
reply views Thread by =?Utf-8?B?U2Vhblc=?= | last post: by
reply views Thread by moondog | last post: by
2 posts views Thread by Aamir Ghanchi | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.