![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| Hey everyone, Peeb here; I haven't posted anything in awhile. But i'm stumped on some small code. Anyway I have a gridview that I'm using to display data from sql. (gridview image here) http://users3.nofeehost.com/peebman/...dviewimage.jpg I have a email link to grab the email address from the 5th cell (text) and the view information button to just grab the id#. The view information button works, but i'm having trouble with the email link button to grab the email text from which ever row the user selects. I tried using this code below to get it to work, but is just posting back its not grabing the email text and I don't understand why this is not working. Code: Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
Dim gridview As GridView = DirectCast(sender, GridView)
If e.CommandName = "email" Then
'Dim index As Object = e.CommandArgument
'Response.Write(index)
'Response.End()
For i As Integer = 0 To GridView1.Rows.Count - 1
If GridView1.SelectedIndex = i Then
Dim value As String = GridView1.Rows(i).Cells(5).Text
Response.Write(value)
Response.End()
End If
Next
'Dim mail As String
''mail = GridView1.Rows(0).Cells(5).Text()
'mail = CType(row.cells(2), DataControlFieldCell).text
'Response.Write(mail)
'Response.End()
End If
'For i As Integer = 0 To GridView1.Rows.Count - 1
' If GridView1.SelectedIndex = i Then
' Dim value As String = GridView1.Rows(i).Cells(5).Text
' End If
'Next
End Sub
|
| Sponsored Links |
|
#2
| ||||
| ||||
| Notice how they use GridViewRow in this example: GridView.RowCommand Event (System.Web.UI.WebControls)
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.Join our Folding team: DeveloperBarn Folding |
| The Following User Says Thank You to jmurrayhead For This Useful Post: | ||
peebman2000 (July 30th, 2008) | ||
|
#3
| |||
| |||
| Thanks jmurrayhead, that worked. I must be like having stupid moments or something. Like I was researching this online, and I even reviewed the MSDN link you gave me, but for some reason it wasn't clicking. So I started coding it with a for loop thinking I needed to code it that way. But looking at the article more thoroughly I see I should have followed the article. But it works now, thanks again. ![]() Code: If e.CommandName = "email" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = GridView1.Rows(index)
'Dim item As New ListItem()
'item.Text = Server.HtmlDecode(row.Cells(5).Text)
Dim value As String = Server.HtmlDecode(row.Cells(5).Text)
Response.Write(value)
Response.End()
End If
Quote:
Last edited by peebman2000; July 30th, 2008 at 10:51 AM. Reason: edit |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The data source 'ObjectDataSource1' does not support sorting with IEnumerable data | Shem | .Net Development | 5 | June 25th, 2008 08:07 AM |
| update gridview dynamically | peebman2000 | .Net Development | 27 | May 8th, 2008 10:03 PM |
| add additional footer to gridview | peebman2000 | .Net Development | 13 | May 2nd, 2008 01:50 PM |
| [ASP.Net/General] Create ToolTip for GridView Header | jmurrayhead | Code Samples | 0 | March 21st, 2008 02:26 PM |