Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
 customize updating the gridview
Posted by ortin on  9/21/2007 9:27:23 AM Category: ADO.NET
Add to my favorites
Email to friend
I want to update the gridview in my own customize way, i have a table called emp1 and in that feilds are empno, empname, sal

<asp:GridView ID="GridView1" runat="server" AllowSorting ="True" OnRowUpdating ="GridView1_RowUpdating"/>
<asp:CommandField HeaderText="Edit" ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True" />

bt in the following event what code i have to type please explain in

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating

End Sub

Post Your Reply Post New Question

 Viewer's Reply
Here it is..
Answered By Moderator1 on 10/10/2007 4:01:35 AM
Dim txtName As TextBox = DirectCast(GridView1.Rows(e.RowIndex).FindControl("txtName"), TextBox)
Dim cmbGender As DropDownList = DirectCast(GridView1.Rows(e.RowIndex).FindControl("cmbGender"), DropDownList)
Dim txtCity As TextBox = DirectCast(GridView1.Rows(e.RowIndex).FindControl("txtCity"), TextBox)
Dim cmbType As DropDownList = DirectCast(GridView1.Rows(e.RowIndex).FindControl("cmbType"), DropDownList)

customer.Update(GridView1.DataKeys(e.RowIndex).Values(0).ToString(), txtName.Text, cmbGender.SelectedValue, txtCity.Text, CustomerType.SelectedValue)
GridView1.EditIndex = -1
Post Your Reply If you still have problem, post it again under this reply for better response.

Sponsored by
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition - Free 207 Page Preview!
No Nonsense XML Web Development With PHP - Free 146 Page Preview!