2 Replies - 5670 Views - Last Post: 05 March 2009 - 08:20 AM Rate Topic: -----

#1 sou9434  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-March 09

How To Update Data Into Girdview Using VB.Net Code?

Posted 04 March 2009 - 12:44 AM

I Have Done The Below Code For Data Update Into Girdview But My Problem Is When I Use gv_RowUpdating() ,is not working.PLeaseeeee Help me how to update data into girdview using Asp.net With VB.Net Code. My Using Code Is Below........... ...

Details.aspx.vb:
		
			Dim SQL As String
			Dim result As Boolean

			Dim vname As TextBox
			Dim vaddress As TextBox
			Dim vphone1 As TextBox
			Dim vphone2 As TextBox
			Dim conper As TextBox
			Dim conpermobno As TextBox
			Dim slno As TextBox


  slno = CType(gv.Rows(e.RowIndex).Cells(0).Controls(0), TextBox)
  vname = CType(gv.Rows(e.RowIndex).Cells(1).Controls(0), TextBox)
  vaddress = CType(gv.Rows(e.RowIndex).Cells(2).Controls(0), TextBox)
  vphone1 = CType(gv.Rows(e.RowIndex).Cells(3).Controls(0), TextBox)
  vphone2 = CType(gv.Rows(e.RowIndex).Cells(4).Controls(0), TextBox)
  conper = CType(gv.Rows(e.RowIndex).Cells(5).Controls(0), TextBox)
  conpermobno = CType(gv.Rows(e.RowIndex).Cells(6).Controls(0),  TextBox)

  SQL = " UPDATE PMS_VENDOR_MASTER "
  SQL = SQL & " SET VENDOR_NAME='" + vname.Text + "', "
  SQL = SQL & " VENDOR_ADDRESS='" + vaddress.Text + "', "
  SQL = SQL & " VENDOR_PHONE='" + vphone1.Text + "', "
  SQL = SQL & " VENDOR_MOBILE_NO='" + vphone2.Text + "', "
  SQL = SQL & " VENDOR_CON_PER_NAME='" + conper.Text + "', "
  SQL = SQL & " VENDOR_CON_PER_MNO='" + conpermobno.Text + "'"
  SQL = SQL & " WHERE"
  SQL = SQL & " VENDOR_SYSID='" + slno.Text + "'"
  result = dba.ExecuteNonQuery(SQL)
  If result = True Then
   lblError.Text = "Data Update Successfully"
   End If
   Catch ex As Exception
   lblError.Text = ex.Message
   End Try
  gv.EditIndex = -1
  gvbound()



Details.aspx

<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" 
			BackColor="White" BorderColor="#666666" BorderStyle="Solid" BorderWidth="1px" 
			CellPadding="6" CssClass="stylenormal" GridLines="Horizontal" 
			ToolTip="List Of Present User" Width="800px" PageSize ="5" 
			AllowPaging="True" DataKeyNames ="VENDOR_SYSID" onrowediting="gv_RowEditing" 
			onrowcancelingedit="gv_RowCancelingEdit" onrowupdating="gv_RowUpdating"
			AutoGenerateEditButton="true" >	
			<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
			<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
			<Columns>
			<asp:BoundField DataField="VENDOR_SYSID" HeaderText="SLNO" 
					ItemStyle-HorizontalAlign="Left">
					<HeaderStyle HorizontalAlign="Left" />
					<ItemStyle HorizontalAlign="Left" />
					
				</asp:BoundField>
			<asp:BoundField DataField="vname" HeaderText="Vendor Name" 
					ItemStyle-HorizontalAlign="Left">
					<HeaderStyle HorizontalAlign="Left" />
					<ItemStyle HorizontalAlign="Left" />
					
				</asp:BoundField>
				<asp:BoundField DataField="vaddress" HeaderText="Vendor Address" 
					ItemStyle-HorizontalAlign="Left">
					<HeaderStyle HorizontalAlign="Left" />
					<ItemStyle HorizontalAlign="Left" />
				</asp:BoundField>
				<asp:BoundField DataField="vphone" HeaderText="Phone Number" 
					ItemStyle-HorizontalAlign="Right">
					<HeaderStyle HorizontalAlign="Right" />
					<ItemStyle HorizontalAlign="Right" />
				</asp:BoundField>
				<asp:BoundField DataField="vmobile" HeaderText="Mobile Number" 
					ItemStyle-HorizontalAlign="Right">
					<HeaderStyle HorizontalAlign="Right" />
					<ItemStyle HorizontalAlign="Right" />
				</asp:BoundField>
				 <asp:BoundField DataField="vconname" HeaderText="Contact Person" 
					ItemStyle-HorizontalAlign="Left">
					<HeaderStyle HorizontalAlign="Left" />
					<ItemStyle HorizontalAlign="Left" />
				</asp:BoundField>
			   <asp:BoundField DataField="vconmobno" HeaderText="Contact Person Mobile Number" 
					ItemStyle-HorizontalAlign="Right">
					<HeaderStyle HorizontalAlign="Right" />
					<ItemStyle HorizontalAlign="Right" />
				</asp:BoundField>
				<asp:CommandField ShowEditButton="True" />

				</Columns>
			<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
			<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
			<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
			<AlternatingRowStyle BackColor="#F7F7F7" />
		</asp:GridView>


Is This A Good Question/Topic? 0
  • +

Replies To: How To Update Data Into Girdview Using VB.Net Code?

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: How To Update Data Into Girdview Using VB.Net Code?

Posted 04 March 2009 - 09:46 AM

Post the code-behind in its entirety for Details.aspx.vb.
Was This Post Helpful? 0
  • +
  • -

#3 woodjom  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 29
  • View blog
  • Posts: 549
  • Joined: 08-May 08

Re: How To Update Data Into Girdview Using VB.Net Code?

Posted 05 March 2009 - 08:20 AM

Also, read up on the Row_Updating and Rows_Updated functions. It took me some time to get a grasp on the difference between these two functions and im still sketchy on some instances. These two functions can cause alot of confusion.

Lastly, are you trying to update the gridview after posting new information into the database? or are you trying to Refresh the gridview to represent potentially new data that might have been updated in the database? What is your usage cause one of these two functions will be your solution, pending on how you intend to try and refresh your gridview.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1