-
1
- #1
I need to know how to programatically get the text value of a hyperlink column in a datagrid. A column in my datagrid is a hyperlink to another page (the field that this column is bound to is used as a key in my SQL tables).
I also have a Delete column on the datagrid that needs to use the value of the hyperlink column to delete records from my table. When I try to access the Text property of the column it says that it is blank.
I have included some code below.
HTML CODE
-------------------------------
<asp:datagrid id="DataGrid1" runat="server" Font-Size="10pt" AlternatingItemStyle-BackColor="#ffffcc" autogeneratecolumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="CaseNbr" DataTextField="CaseNbr" HeaderText="Case #" NavigateUrl="Details.aspx"></asp:HyperLinkColumn>
</Columns>
</asp:datagrid>
VB CODE
------------------------------
Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
Dim index As Integer
index = e.Item.ItemIndex
' Add code to delete data from data source.
Dim de As String
de = DataGrid1.Items(index).Cells(0).Text
End Sub
I also have a Delete column on the datagrid that needs to use the value of the hyperlink column to delete records from my table. When I try to access the Text property of the column it says that it is blank.
I have included some code below.
HTML CODE
-------------------------------
<asp:datagrid id="DataGrid1" runat="server" Font-Size="10pt" AlternatingItemStyle-BackColor="#ffffcc" autogeneratecolumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="CaseNbr" DataTextField="CaseNbr" HeaderText="Case #" NavigateUrl="Details.aspx"></asp:HyperLinkColumn>
</Columns>
</asp:datagrid>
VB CODE
------------------------------
Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
Dim index As Integer
index = e.Item.ItemIndex
' Add code to delete data from data source.
Dim de As String
de = DataGrid1.Items(index).Cells(0).Text
End Sub