Datagrid Row Selected

Discussion in 'ASP .Net' started by Luis E Valencia, May 10, 2004.

  1. 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?
    Luis E Valencia, May 10, 2004
    #1
    1. Advertising

  2. 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" <> escribió en el mensaje
    news:...
    > 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
    >
    Luis E Valencia, May 10, 2004
    #2
    1. Advertising

  3. 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
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 10, 2004
    #3
  4. It is not useful
    For Each di In dl.Items


    I tried di.Items

    but not





    "Bin Song, MCP" <> escribió en el mensaje
    news:...
    > 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
    Luis E Valencia, May 10, 2004
    #4
  5. Did you try the selectedItemTemplate?
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 11, 2004
    #5
  6. this is a datagrid not a datalist
    "Bin Song, MCP" <> escribió en el mensaje
    news:...
    > Did you try the selectedItemTemplate?
    Luis E Valencia, May 11, 2004
    #6
  7. 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
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 11, 2004
    #7
  8. It inderlines this line

    If e.Item.CommandName = "Pasar" Then





    "Bin Song, MCP" <> escribió en el mensaje
    news:...
    > 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
    >
    >
    Luis E Valencia, May 11, 2004
    #8
  9. Sorry, I don't get it

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

    It inderlines this lin

    If e.Item.CommandName = "Pasar" The
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 11, 2004
    #9
  10. Vs.net underlines that line


    "Bin Song, MCP" <> escribió en el mensaje
    news:...
    > Sorry, I don't get it.
    >
    > ----- Luis E Valencia wrote: -----
    >
    > It inderlines this line
    >
    > If e.Item.CommandName = "Pasar" Then
    >
    >
    Luis E Valencia, May 11, 2004
    #10
  11. Sorry my fault again
    If e.CommandName = "Pasar" The
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 11, 2004
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U3VyZXNo?=
    Replies:
    1
    Views:
    451
    Saravana
    Nov 22, 2004
  2. Charles Shao
    Replies:
    1
    Views:
    389
    Eliyahu Goldin
    Apr 18, 2005
  3. Want to add row under selected row of gridview

    , Feb 16, 2007, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    292
  4. D
    Replies:
    0
    Views:
    197
  5. Selected Row Only GridView Row Visible?

    , Oct 17, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    280
Loading...

Share This Page