954,206 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

datagrid hyperlink

I have a datagrid in my webform with two columns namely empno and empname. The column empname is a hyperlink column. When the page loads both the columns are displaying data from the emp table. There are totally 5 records in the emptable. So five rows are getting displayed in the datagrid. Fine. There are other columns in the emptable namely salary and designation which should be displayed in the appropriate textboxes whenever a particular empname(Hyperlink column) for e.g "Ram" which is the second record in the grid is clicked. Similarly if the third record empname(hyperlink column) is clicked the salary details and designation details should be populated in the appropriate textboxes. How to achieve this? Pls help me with full coding. I am using vb.net

crprajan
Newbie Poster
3 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

We need to see your code to be more helpful. But basically you need an event handler for the datagrids ItemCommand event. Use the DataGridItemEventArgs object that is passed as a parameter to the handler to determine which link was clicked and the empno it represents, query the database and populate the textboxes.

hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
 

You need to do several things. This basically a break down of what Hollystyles suggested. Please pay close attention.
edit the html code and edit the Itemcommand property(add a command name)
[html]


[/html]


This summarizes what you already have now just add the OnItemCommand="Grid_EmpCommand" to the datagrid and the
CommandName="updateTextBoxes" to the linkbutton. Open the code screen and add the following

Sub Grid_EmpCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
' e.Item is the table row where the command is raised.
' For bound columns, the value is stored in the Text property of the TableCell.
Dim empNoCell As TableCell = e.Item.Cells(1)
Dim empnameCell As TableCell = e.Item.Cells(2)
 
Dim empNo As String = empNoCell.Text
Dim empName As String = empnameCell.Text
 
'Assign to the text boxes
If CType(e.CommandSource, LinkButton).CommandName = "updateTextBoxes" Then
textbox1.text = sEmpno
textbox2.text = sEmpname

This should work. Please get back to me:cool:I have a datagrid in my webform with two columns namely empno and empname. The column empname is a hyperlink column. When the page loads both the columns are displaying data from the emp table. There are totally 5 records in the emptable. So five rows are getting displayed in the datagrid. Fine. There are other columns in the emptable namely salary and designation which should be displayed in the appropriate textboxes whenever a particular empname(Hyperlink column) for e.g "Ram" which is the second record in the grid is clicked. Similarly if the third record empname(hyperlink column) is clicked the salary details and designation details should be populated in the appropriate textboxes. How to achieve this? Pls help me with full coding. I am using vb.net

jamello
Posting Whiz in Training
219 posts since Oct 2006
Reputation Points: 215
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You