473,796 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to selected rows on gridview?

29 New Member
Hi, I'm having problem with my rows on gridview. When i click on the approve button, only the first row of the grid will update. Does anyone know how to make it that when i click on the different button on different row different rows will update. My code is as below...

Sub CustomersGridVi ew_RowCommand(B yVal sender As Object, ByVal e As GridViewCommand EventArgs)

' If multiple buttons are used in a GridView control, use the
' CommandName property to determine which button was clicked.

Dim str As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source= " & Server.MapPath( "database\db1.m db")

If e.CommandName = "Approve" Then
'Str = "Update Table3 Set Status='6' Where Status =''"
'myCommand = New OleDbCommand(St r, con)
'myCommand.Exec uteNonQuery()
'Label1.Text = ("Successful ly Approve")
'con.Close()

'Dim index As Integer
Dim mySelectQuery As String = "SELECT State, FileID FROM Table3"
Dim row As GridViewRow = GridView1.Selec tedRow
Dim myUpdateQuery As String = "Update Table3 Set State='6' where FileID=" & "'" & row.Cells(1).Te xt & "'" & ""

Dim myConnection As New OleDbConnection (Str)

Dim myCommand As New OleDbCommand(my SelectQuery, myConnection)

Dim myCommand2 As New OleDbCommand(my UpdateQuery, myConnection)

Dim retvalue As Integer

myConnection.Op en()

myCommand2.Exec uteNonQuery()

Console.WriteLi ne(retvalue)

Dim myReader As OleDbDataReader

myReader = myCommand.Execu teReader()

'Always call Read before accessing data.

While myReader.Read()
Label1.Text = ("Successful ly Approve")

End While

'always call Close when done reading.

myReader.Close( )

'Close the connection when done with it.

myConnection.Cl ose()
End If
Apr 16 '07 #1
2 1579
Teenzonez
36 New Member
Hi
Is it like this that there are approve buttons on every row on the gridview and that if you click on any button on any of the rows only the first row will be updated?
Please make it clear.

Regards
TeenzoneZ
Apr 16 '07 #2
fanoftvb
29 New Member
Hi
Is it like this that there are approve buttons on every row on the gridview and that if you click on any button on any of the rows only the first row will be updated?
Please make it clear.

Regards
TeenzoneZ
Yes, there is a approve button on every row and if you click on the first button, the first row will update, click on the second button and the second row will update etc.
Apr 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
35620
by: Neil | last post by:
I have a gridview which is being populated with no problems. I want to be able to reference the data from the cells in the row but having followed an example on MSDN cannot get any data to be displayed in a text box no matter which cell index I provide. I tried a row of code that successfully displays the rowindex of the selected row. The code with comments is below:
5
4840
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens automatically if the data doesn't change. But if records have been added or deleted then it looks as if some code is necessary: I've done this by using GridView.SelectedValue to get the key value of the currently selected Row and then by itterating...
3
23544
by: Karl Rhodes | last post by:
I have a datagridview which is populated via a datatable. What I would like to dynamically set a selected row and have that row show up in the datagridview and not have to manually scroll to find the selected row. I had a look for all kind of "datagridview1.rows(i).focus" but there doesnt seem to be anything. Can anyone help? I know this must be quite simple to do but cant find it.
1
7493
by: jobs | last post by:
Given the Gridview below: When I select the button "Rate" and fall into this code. How can I reference "carriercode" and others . Apparently selecting the button does not select the row. I've tried find control, and everything returns that I must reference and instance of the object. CommandArgument is being sent corrently. If the button where a ButtunField I apparently I could get the get the index, But I need the button to be an...
0
3736
by: Child X | last post by:
Hi all, I have a web form with two GridViews on it. GridView 'A' populates GridView 'B' based on it 'SelectedRowValue'. What i am after, is ...if someone delete a row from grid 'A' and it is currently the 'SelectedRow'... I want to decrement GridViews selected index by 1 so it falls to the
1
1968
by: Steve Kershaw | last post by:
Hi, I have a GridView in which I have selected a row. I now want to use the 1st column value of that selected row in another GridView as an input to select the particular row in the second GridView. I know that "GridView1.SelectedRow.Cells" dosen't work along with some other things I have tried. Can anybody help me with this?!
2
2117
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent back the proper number of rows. The only thing different I am doing is to display the number of rows returned in the footer of the gridview. The Bindgrid is as follows: Sub BindGrid() Session("reportlevel") = Session("availabilityrptlevel")
3
11466
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview with one of the columns as a template column with a button. When the user selects the button is there a way to get the row number in the button_Click event? Another one of the columns is a template column that has a label that I have displaying the row number. Thanks -- Paul G Software engineer.
1
5646
by: imbirek8 | last post by:
Hi, I use GridView control in asp.net. I would like to write an event on the client site. When somebody click on row, I would like to clear all selected rows in GridView and changed cliked row color in permanent way. How to do it in JavaScript ? Thank you for help
0
9527
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.