Autogeneratecolumns = true, and I want to edit

A

Andy Sutorius

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
 
T

Trevor Benedict R

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!
 
S

Sandeep Kayal

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top