Make Editable All Rows of Gridview By single Button click

Posted by Alok under ASP.NET on 9/30/2012 | Points: 10 | Views : 2988 | Status : [Member] | Replies : 2
Hi,
I Have a Gridview and a Button outside Gridview on Page.
I want to make all rows of Gridview Editable on click event of Button.

Note: i want editable all rows of gridview simultaneously not only single rows.

Thanks & Regards,
Alokssm



Responses

Posted by: Jpchoudhari on: 10/1/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

I don't think you can do so using gridview because to make a row editable one have to set the edit index of the grid and that we can set one at a time


Kind Regards,
Jay

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Divyaselvarathinam on: 10/3/2012 [Member] Starter | Points: 25

Up
0
Down
Test with this code..


Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click

sqlconn.Open()

Dim city, id As String

For Each row In Grid1.Rows

'txtcity is the textbox of grid that is to be updated

city = CType(row.Cells(2).FindControl("txtCity"), TextBox).Text

'cells(0) is the boundfield of grid tat has id value

id = row.cells(0).text

command = New SqlCommand("update Emp_Details set city='" & city & "' WHERE Id ='" & id & "'", sqlconn)

command.ExecuteScalar()

Next

Grid1.DataBind()

sqlconn.Close()

End Sub

Divya

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response