Datagrid question

  • Thread starter Thread starter thewhoracle
  • Start date Start date
T

thewhoracle

I have a datagrid, and I have a column that must do the following.

-if each row's data member in this column has a certain sequence of
characters, it must have a link associated with it that goes to a
website that uses the data in this member as part of the address.

I'm new at asp.net. I need to know how to conditionally add links
when the datagrid gets filled, and i need to know how to get the value
of the member in the column and insert it into the URL for the link.

thank you
 
You can use the DataGrids onItemDataBound Method to manipulate a datagrids
elements before it is rendered.

Mostlikely to acheive what you are after you will have something like:

Sub myGrid_onItemDataBound(sender As Object, e As DataGridItemEventArgs)
Dim myHyperLink As HyperLink

If(e.Item.ItemType = ListItem.Item Or e.Item.ItemType =
ListItem.AlternatingItem) Then

If(e.Item.DataItem(?) = "xyz") Then

myHyperLink = new HyperLink
myHyperLink.NavigateUrl = ?
e.Item.Cells(?).Controls.Add(myHyperLink)
e.Item.Cells(?).Controls.RemoveAt(?)

End If

End If

End Sub

This is completely off the top of my head and untested.
But should given an indication of what you need to do.

Cheers,
Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top