473,378 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Datagrid Row Selected

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
10 2043
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
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
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
Did you try the selectedItemTemplate?
Nov 18 '05 #5
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
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
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
Sorry, I don't get it

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

It inderlines this lin

If e.Item.CommandName = "Pasar" The
Nov 18 '05 #9
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
Sorry my fault again
If e.CommandName = "Pasar" The

Nov 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paul | last post by:
Hey there, I have a DataGrid bound to a DataTable. When a user selects a row, I want to send the UNQ_ID (which is in a column with a width of zero, or it's visible parameter set to false) for...
4
by: R Agam | last post by:
How do I get the selected Rows index in the DataGrid? Thanks, Ronen
1
by: GregM | last post by:
I have a read only datagrid that is designed to coordinate itself with textboxes. When the user clicks on a row in the datagrid, detailed data for that row is displayed for editing in the...
0
by: thomaz | last post by:
How can i capture the X (columns) and Y (lines) coordinates of a specific cell (like the FIRST CELL) of only selected lines of a DataGrid. There is a specific method to do it? There is a loop...
2
by: Richard | last post by:
DataGrid Row Second Row Selected. How do I not show that blank row with the > abc abc abc abc > abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc xx yyyyyyyyyyyyyy
1
by: simon | last post by:
How do you display selected records in a datagrid and eventually update them? tia simon
4
by: rodchar | last post by:
hey all, when you first load a page with a datagrid item on it, is the first record always selected by default? if so, is there a way to have it where nothing is selected by default? thanks,...
2
by: Alex | last post by:
I have a datagrid with some dynamically generated columns containing linkButtons. How can I wire these events to fire the datagrid_SelectedIndexChanged? When clicking a template column defined...
3
by: Alan | last post by:
How do I find out the selected row in a datagrid ?
0
by: Ed Dror | last post by:
Hi there, I'm using Visual studio 2005 pro and I want to pass parameter from datagrid selected cell to textbox I have Select button in my datagrid I wrote this Protected Sub...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.