.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 25th, 2005, 10:00 AM
method method is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 54 method User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 45 m 12 sec
Reputation Power: 4
Angry How to pass datagrid record number instead of clicking

I got a datagrid that supposed to edit the datagrid once the user clicks on edit button next to each record. I want this page recives the record number as passed value but i do not know how to do it .(datagridupdate?record=4)
Is there a way to pass record value to this part of code which is resposible for finding the record that we want to update ? I be happy to get some help here. thanks
Code:
	Sub DBEditDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
		DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
		DataBindGrid
	End Sub



Code:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script language="VB" runat="server">
 Dim objConnection As SqlConnection
 Dim myDataReader As SqlDataReader 

	Sub Page_Load(Sender As Object, E As EventArgs) 
  ' Set up our connection.
  objConnection = New SqlConnection("Data Source=(local);" _
   & "Initial Catalog=teniss2;User Id=web;Password=web;" _
   & "Connect Timeout=15;Network Library=dbmssocn;")

  LoadDataFromDB

  If Not IsPostBack Then
   DataBindGrid
  End If
	End Sub

 Sub LoadDataFromDB()
  Dim objCommand As SqlCommand

  ' Create new command object passing it our SQL query
  ' and telling it which connection to use.
  objCommand = New SqlCommand("SELECT * FROM Players;", objConnection)

  ' Open the connection, execute the command, and close the connection.
  objConnection.Open()
  myDataReader = objCommand.ExecuteReader(System.Data.CommandBehavi  or.CloseConnection)
 End Sub

	Sub DataBindGrid()
		DBEditDataGrid.DataSource = myDataReader
		DBEditDataGrid.DataBind
	End Sub

	Sub DBEditDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
		DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
		DataBindGrid
	End Sub

.......
.......

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > How to pass datagrid record number instead of clicking


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT