开发者

Editing a row in a gridview

I have a t开发者_JAVA技巧wo text boxes named region id and region name..and a button control

I enter some values into those text boxes and click the button to insert those values into the "gridview"and a "data table" associated with the gridview.

The gridview has the "enable editing" set to true..but when i click the "edit" button of a particular row in a gridview i get no response...i.e i do not get editable textboxes as it happens normally...

What is the solution for this?


You need to set the EditIndex of the row you are editting on the gdvMyGridView_RowEditing event:

gdvMyGridView.EditIndex = e.NewEditIndex

This will display your EditItemTemplate for the relevant row.


GridView Examples for ASP.NET 2.0: Editing the Underlying Data in a GridView

Editable GridView in ASP.NET 2.0


Edit control does not work out of blue. You have to write a backend SQL query for it to implement. The query will most likely look like this.

update regions SET name=@name where ID=@ID

where name and ID are fields of the table. Make sure the ID is the primary key, otherwise update will not work and you won't get any error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜