By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

Datagrid Row Selected

P: n/a
I have many datagrids on a page, and an ItemCommand on one datagrid that
displays another datagrid dependin on what selected in first datagrid on the
VIew Column(Item Command) How Can I keep the first datagird row selected
in another color?
Nov 18 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Cool the second one worked for me.
But
When I select 2 , the last one also stays selected I want to remove the last
selected one.

"Bin Song, MCP" <an*******@discussions.microsoft.com> escribió en el mensaje
news:6F**********************************@microsof t.com...
Hi,

2 Ways to change the color of the row selected:
One is to specify a style in template:
<SelectedItemStyle BackColor="red"></SelectedItemStyle>
another way is to add through your itemcommand
Sub DataList_ItemCommand(sender As Object, e As DataListCommandEventArgs) If e.Item.CommandName = "View" Then
e.Item.BackColor = Color.Red
End If
End Sub

Bin Song, MCP

Nov 18 '05 #2

P: n/a
Hi

That's the problem of programmatically control. You have to take care of everything
You can add the following code to reverse the backcolor to normal(if it is white)
Dim di As DataListIte
For Each di In dl.Item
If di.ItemIndex <> e.Item.ItemIndex and di.BackColor <> Color.White The
di.BackColor = Color.Whit
End I
Nex
Of course another way is to remmember the previous selected itemindex. in this case SelectedItemStyle is better
<SelectedItemStyle BackColor="red"></SelectedItemStyle
An
Sub DataList_ItemCommand(sender As Object, e As DataListCommandEventArgs
If e.Item.CommandName = "View" The
DataList.SelectedIndex = e.Item.ItemInde
Datalist.DataBind(
End I
End Sub

Bin Song, MCP
Nov 18 '05 #3

P: n/a
It is not useful
For Each di In dl.Items
I tried di.Items

but not

"Bin Song, MCP" <an*******@discussions.microsoft.com> escribió en el mensaje
news:8E**********************************@microsof t.com...
Hi,

That's the problem of programmatically control. You have to take care of everything. You can add the following code to reverse the backcolor to normal(if it is white): Dim di As DataListItem
For Each di In dl.Items
If di.ItemIndex <> e.Item.ItemIndex and di.BackColor <> Color.White Then di.BackColor = Color.White
End If
Next
Of course another way is to remmember the previous selected itemindex. in this case SelectedItemStyle is better. <SelectedItemStyle BackColor="red"></SelectedItemStyle>
And
Sub DataList_ItemCommand(sender As Object, e As DataListCommandEventArgs) If e.Item.CommandName = "View" Then
DataList.SelectedIndex = e.Item.ItemIndex
Datalist.DataBind()
End If
End Sub

Bin Song, MCP

Nov 18 '05 #4

P: n/a
Did you try the selectedItemTemplate?
Nov 18 '05 #5

P: n/a
this is a datagrid not a datalist
"Bin Song, MCP" <an*******@discussions.microsoft.com> escribió en el mensaje
news:B1**********************************@microsof t.com...
Did you try the selectedItemTemplate?

Nov 18 '05 #6

P: n/a
Sorry I missed that
You can try SelectedItemStyle
<SelectedItemStyle BackColor="red"></SelectedItemStyle
An
Sub DataGrid_ItemCommand(sender As Object, e As DataGridCommandEventArgs
If e.Item.CommandName = "View" The
DataGrid.SelectedIndex = e.Item.ItemInde
DataGrid.DataBind(
End I
End Sub
Nov 18 '05 #7

P: n/a
It inderlines this line

If e.Item.CommandName = "Pasar" Then

"Bin Song, MCP" <an*******@discussions.microsoft.com> escribió en el mensaje
news:20**********************************@microsof t.com...
Sorry I missed that.
You can try SelectedItemStyle.
<SelectedItemStyle BackColor="red"></SelectedItemStyle>
And
Sub DataGrid_ItemCommand(sender As Object, e As DataGridCommandEventArgs) If e.Item.CommandName = "View" Then
DataGrid.SelectedIndex = e.Item.ItemIndex
DataGrid.DataBind()
End If
End Sub

Nov 18 '05 #8

P: n/a
Sorry, I don't get it

----- Luis E Valencia wrote: ----

It inderlines this lin

If e.Item.CommandName = "Pasar" The
Nov 18 '05 #9

P: n/a
Vs.net underlines that line
"Bin Song, MCP" <an*******@discussions.microsoft.com> escribió en el mensaje
news:29**********************************@microsof t.com...
Sorry, I don't get it.

----- Luis E Valencia wrote: -----

It inderlines this line

If e.Item.CommandName = "Pasar" Then

Nov 18 '05 #10

P: n/a
Sorry my fault again
If e.CommandName = "Pasar" The

Nov 18 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.