AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
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"/>
<Columns>
<asp:CommandField HeaderText="Edit" ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True" />

bt in the following event what code i have to type please explain in vb.net:

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
FillCustomerInGrid()
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Windows 8: 50 Questions and Answers You Need to Make a Decision (Normally $9.95)
Introduction to Software Development
The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition - Free 207 Page Preview!