|
 |
aspx thread: DataGrid question
Message #1 by "Arbon Reimer" <arbon@l...> on Tue, 12 Mar 2002 22:13:26 -0700
|
|
Hello, I have another question.
I am using a DataGrid on one page, and it works brilliantly... there is one
functionality I would like to include but am not sure how to go about it.
When someone sends a URL parameter to the page with the DataGrid, I want the
background color of the table row to change color for matching criteria in
the data... example:
Someone selects Position #34, and in my datagrid I have one column "Position
Number" and "Position Description". And when someone calls the page as in
positions.aspx?Position=34 I want the table row with Position Number 34 to
have a different background color than the rest of the datagrid.
Is this a possibility using a DataGrid? Thanks everyone for their help!
Arbon Reimer
Golden, Colorado
Message #2 by "Lewis Bass" <lewis@t...> on Wed, 13 Mar 2002 08:29:34 -0700
|
|
You can do it if you write an event handler for the ItemDataBound event.
Here is one where I set the background color
Private Sub dgDisplayResults_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgDisplayResults.ItemDataBound
Dim bar_code As String
Dim ck As Object
Dim ckcnt As Integer
Dim i As Integer
If e.Item.ItemIndex >= 0 Then
bar_code = e.Item.Cells(2).Text
' if the barcode has been requested then change the color
If Session("checkcount") > 0 Then
ck = Session("checkarray")
For i = 0 To (Session("checkcount"))
If Trim(bar_code) = Trim(ck(i)) Then
e.Item.BackColor = System.Drawing.Color.FromArgb(0, 255, 0)
End If
Next i
End If
End If
End Sub
----- Original Message -----
From: "Arbon Reimer" <arbon@l...>
To: "ASP+" <aspx@p...>
Sent: Tuesday, March 12, 2002 10:13 PM
Subject: [aspx] DataGrid question
> Hello, I have another question.
>
> I am using a DataGrid on one page, and it works brilliantly... there is
one
> functionality I would like to include but am not sure how to go about it.
>
> When someone sends a URL parameter to the page with the DataGrid, I want
the
> background color of the table row to change color for matching criteria in
> the data... example:
>
> Someone selects Position #34, and in my datagrid I have one column
"Position
> Number" and "Position Description". And when someone calls the page as in
> positions.aspx?Position=34 I want the table row with Position Number 34 to
> have a different background color than the rest of the datagrid.
>
> Is this a possibility using a DataGrid? Thanks everyone for their help!
>
> Arbon Reimer
> Golden, Colorado
>
>
|
|
 |