Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink Column

Status
Not open for further replies.

JoeZim

MIS
Sep 11, 2003
87
US
I've got the following Datagrid columns:

Code:
<Columns>
	<asp:BoundColumn DataField="h_name" HeaderText="Name"></asp:BoundColumn>
	<asp:BoundColumn DataField="h_exposure" HeaderText="Insur Amt"></asp:BoundColumn>
	<asp:BoundColumn DataField="h_ind" HeaderText="Future Ind"></asp:BoundColumn>
	<asp:BoundColumn DataField="sw_insur" HeaderText="Hazard Ins"></asp:BoundColumn>
	<asp:BoundColumn DataField="sw_type" HeaderText="Deposit Acct"></asp:BoundColumn>
	<asp:HyperLinkColumn Text="sw_excep" DataTextField="sw_excep" HeaderText="Docu Excep" NavigateUrl="SearchDetailsExpand.aspx"></asp:HyperLinkColumn>
	<asp:HyperLinkColumn Text="sw_life" DataTextField="sw_life" HeaderText="Life Insur" NavigateUrl="SearchDetailsExpand.aspx"></asp:HyperLinkColumn>
</Columns>

When a user clicks the Hyperlink, I want it to redirect them to a new page, which will display the appropriate detail. I'm trying to capture the "Header Text" and the actual text of the hyperlink. I've been able to capture the Header text (it is hardcoded), but I've not been able to capture the actual hyperlink text. Here is what I have:

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        Panel1.Controls.Add(Me.LoadControl("Banner.ascx"))
        Panel2.Controls.Add(Me.LoadControl("Left.ascx"))

        Dim cf As New MandT.CLD.Inquiry.BusinessTier.BLL

        ObligorAllDataSet = cf.GetObligorAll(Session("obligor"))
        DetailMaster.DataSource = ObligorAllDataSet
        DetailMaster.DataBind()

    End Sub

Private Sub DetailMaster_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DetailMaster.ItemDataBound

        Dim i As Integer = e.Item.Cells.Count - 1


        Dim strType As String = CType(DetailMaster.Controls(0).Controls(1), DataGridItem).Cells(e.Item.Cells.Count - 2).Text ' Header Text with hard coding the cell index




        Session("ExpandType") = strType
        Session("ExpandValue") = strValue

    End Sub

I was hoping to capture the text of the hyperlink itself and then evaluate before the redirect (it is a "Y" or "N"). Also, since there are two hyperlink columns, is there a way to capture which column is being clicked and it's corresponding header (I have it hard coded right now).
 
I was able to pass the Hyperlink value after understanding the "URL Format String" field:

SearchDetailsExpand.aspx?sw_life={0}

Now, is there any way to detect the header value of the hyperlink being clicked? Currently, I have the following code in the DetailMaster_ItemDataBound:

Code:
Dim strType As String = CType(DetailMaster.Controls(0).Controls(1), DataGridItem).Cells(e.Item.Cells.Count - 2).Text

Session("ExpandType") = strType

It reads the header item, but I have to hard code which cell in the header I'm pulling:

Code:
Dim strType As String = CType(DetailMaster.Controls(0).Controls(1), DataGridItem).Cells(e.Item.Cells.Count - 2).Text

Is there a way to have it know which header value corresponds with the hyperlink value being clicked, without explicitly coding:

Cells(e.Item.Cells.Count - 2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top