Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid Row Selected

Reply
Thread Tools

Datagrid Row Selected

 
 
Luis E Valencia
Guest
Posts: n/a
 
      05-10-2004
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?


 
Reply With Quote
 
 
 
 
Luis E Valencia
Guest
Posts: n/a
 
      05-10-2004
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" <(E-Mail Removed)> escribiˇ en el mensaje
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
Guest
Posts: n/a
 
      05-10-2004
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
 
Reply With Quote
 
Luis E Valencia
Guest
Posts: n/a
 
      05-10-2004
It is not useful
For Each di In dl.Items


I tried di.Items

but not





"Bin Song, MCP" <(E-Mail Removed)> escribiˇ en el mensaje
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
Guest
Posts: n/a
 
      05-11-2004
Did you try the selectedItemTemplate?
 
Reply With Quote
 
Luis E Valencia
Guest
Posts: n/a
 
      05-11-2004
this is a datagrid not a datalist
"Bin Song, MCP" <(E-Mail Removed)> escribiˇ en el mensaje
news:(E-Mail Removed)...
> Did you try the selectedItemTemplate?



 
Reply With Quote
 
=?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
Guest
Posts: n/a
 
      05-11-2004
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


 
Reply With Quote
 
Luis E Valencia
Guest
Posts: n/a
 
      05-11-2004
It inderlines this line

If e.Item.CommandName = "Pasar" Then





"Bin Song, MCP" <(E-Mail Removed)> escribiˇ en el mensaje
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
=?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
Guest
Posts: n/a
 
      05-11-2004
Sorry, I don't get it

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

It inderlines this lin

If e.Item.CommandName = "Pasar" The


 
Reply With Quote
 
Luis E Valencia
Guest
Posts: n/a
 
      05-11-2004
Vs.net underlines that line


"Bin Song, MCP" <(E-Mail Removed)> escribiˇ en el mensaje
news:(E-Mail Removed)...
> Sorry, I don't get it.
>
> ----- Luis E Valencia wrote: -----
>
> It inderlines this line
>
> If e.Item.CommandName = "Pasar" Then
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to add row under selected row of gridview ujjc001@gmail.com ASP .Net Building Controls 1 02-16-2007 07:14 PM
Selected Row Only GridView Row Visible? needin4mation@gmail.com ASP .Net Web Controls 0 10-17-2006 10:07 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
How to chang bgcolor of row when mouse selected a row? Charles Shao ASP .Net 1 04-18-2005 11:11 AM
How to add a new row to a datagrid with values of the selected row =?Utf-8?B?U3VyZXNo?= ASP .Net 1 11-22-2004 09:04 AM



Advertisments