This is a migrated thread and some comments may be shown as answers.

Get Row Index Value - Server Side

2 Answers 184 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 06 Feb 2012, 08:34 PM

I am having some trouble figuring out how to get the row index value from the radgrid.

Using Microsoft Gridview I 've been able to accomplish the following:

 

Dim row As GridViewRow = DirectCast(btnDetails.NamingContainer, GridViewRow)

 

 

'Grab the LabAcc_PK and feed it to the Lab details datasource
' finally, rebind the detailview

  
DBConnect.Open()

cmd.Connection = DBConnect
cmd.CommandType = Data.CommandType.StoredProcedure

cmd.CommandText = "usp_GetLabAccountDetails"

 
 'Add Parameters of SQL Procedure

 
cmd.Parameters.AddWithValue("LabAcc_PK", Convert.ToString(Gridview1.(row.RowIndex).Value))


How do I do the same thing but using the radgrid.

thanks -

2 Answers, 1 is accepted

Sort by
0
Charles
Top achievements
Rank 1
answered on 07 Feb 2012, 03:10 AM
For anyone else looking for a simple solution!!!

Protected Sub BtnViewDetails_Click(ByVal sender As Object, ByVal e As EventArgs)
 
       '  get the gridviewrow from the sender so we can get the datakey we need
 
       Dim btnDetails As ImageButton = TryCast(sender, ImageButton)
       Dim item As GridDataItem = DirectCast(btnDetails.NamingContainer, GridDataItem)
       Dim ID As String = item.GetDataKeyValue("LabAcc_Pk").ToString()
 
       '  extract the LabACC_PK Indentity from the row whose details button originated the postback.
       '  grab the LabAcc_PK and feed it to the Lab details datasource
       '  finally, rebind the detailview
 
       DBConnect.Open()
       cmd.Connection = DBConnect
       cmd.CommandType = Data.CommandType.StoredProcedure
       cmd.CommandText = "usp_GetLabAccountDetails"
 
       'Add Parameters of SQL Procedure
       cmd.Parameters.AddWithValue("LabAcc_PK", ID)
0
Danny
Top achievements
Rank 1
answered on 19 Feb 2013, 11:21 AM
Thanks for your post Charles. Just what I was looking for.
Tags
Grid
Asked by
Charles
Top achievements
Rank 1
Answers by
Charles
Top achievements
Rank 1
Danny
Top achievements
Rank 1
Share this question
or