2

In my website, I have a gridview which has datasource dynamically bound from database table.

Now I want that when a user clicks in a cell of the gridview it becomes editable and he can edit the cell values and update the database accordingly.

I don't wish to use the in-built edit, delete and update buttons of gridview. How can I do that?

halfer
  • 19,824
  • 17
  • 99
  • 186
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216

2 Answers2

0

I guess if you catch the client side click on the grid you can them force a post back in which you set the selected row to edit mode. Is this what you want to do?

Davide Piras
  • 43,984
  • 10
  • 98
  • 147
0
  1. Inside awareness cell declare (for example) div or span with specified ID.
  2. Using javascript declare onclick handler for this div/span
  3. Follow this simplest example http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx
Dewfy
  • 23,277
  • 13
  • 73
  • 121
  • So how will it help in updating the changes back into the database? – Parth Bhatt Jan 20 '11 at 08:59
  • @PARTH, note that written relates to non-ajax approach. When postback event handled you just need call `GridView.SetEditRow` method. That will show grid in edit mode. Number of row you can code in javascript, so it will be pass as argument of event – Dewfy Jan 20 '11 at 09:05
  • Is there any code available which I can refer to. It would help me understand that in a better way. – Parth Bhatt Jan 20 '11 at 09:11
  • @PARTH - you are really lazy :) 5 seconds googling I've found next sample: http://weblogs.asp.net/andrewrea/archive/2008/08/04/gridview-row-click-selection-via-clientside-code.aspx – Dewfy Jan 20 '11 at 09:45
  • @Dewfy: Its not about being lazy but I can google it only when I understand what actually you are trying to say. Thanks by the way. – Parth Bhatt Jan 20 '11 at 09:49
  • @PARTH - I hope technique described in my answer help you to understand entire example. By the way, there is another approach - but it uses AJAX, and concerned with writing special web-services to manage editing – Dewfy Jan 20 '11 at 10:11