Datalist selects Item after first click, but does apply the SelectedItemTemplate after the second cl

Discussion in 'ASP .Net' started by Dirk Meusel, Aug 7, 2003.

  1. Dirk Meusel

    Dirk Meusel Guest

    Background:
    On my webform a simple datalist shows one column. The databind is done
    in the page_load event. In the ItemTemplate a linkbutton serves for
    providing the Select Command.

    Problem:
    When I click a item to be selected, the datalist applies the
    SelectedItemStyle on that Item, but not the SelectedItemTemplate. When
    I click the same Item a second time asp.net applies both the
    SelectedItemStyle and the SelectedItemTemplate, but does not fire the
    OnSelectedItemChanged event.

    What is to do to select the item with the first click properly???
    Dirk Meusel, Aug 7, 2003
    #1
    1. Advertising

  2. Dirk Meusel

    Dirk Meusel Guest

    Thank you, Bülent Keskin! I forgot to databind the datalist after
    postback again. with a databind() statement in the page_load event,
    everything works fine.

    Dirk


    "Bülent Keskin" <> wrote in message news:<#>...
    > A good programming structure for DataGrids: (sorry for possible syntax
    > errors..)
    > ----------------------------------------------
    >
    > private void GridBind()
    > {
    > DataGrid1.DataSource = ....
    > DataGrid1.DataBind();
    > }
    >
    > public void Page_Load(object sender, EventArgs e)
    > {
    > if(!IsPostBack){
    > GridBind();
    > }
    > }
    >
    > private void DataGrid1_SelectEvent....
    > {
    > DataGrid1.SelectedIndex = e.Item.ItemIndex;
    > GridBind();
    > }
    >
    > private void DataGrid1_PageChangeEvent....
    > {
    > DataGrid1.CurrentPageIndex = e.NewPageIndex;
    > GridBind();
    > }
    >
    >
    > "Dirk Meusel" <-dresden.de> wrote in message
    > news:...
    > > Background:
    > > On my webform a simple datalist shows one column. The databind is done
    > > in the page_load event. In the ItemTemplate a linkbutton serves for
    > > providing the Select Command.
    > >
    > > Problem:
    > > When I click a item to be selected, the datalist applies the
    > > SelectedItemStyle on that Item, but not the SelectedItemTemplate. When
    > > I click the same Item a second time asp.net applies both the
    > > SelectedItemStyle and the SelectedItemTemplate, but does not fire the
    > > OnSelectedItemChanged event.
    > >
    > > What is to do to select the item with the first click properly???
    Dirk Meusel, Aug 19, 2003
    #2
    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. Harry
    Replies:
    1
    Views:
    558
    Ather Ali Shaikh
    Jan 17, 2004
  2. Raymond Du
    Replies:
    1
    Views:
    466
    Johann MacDonagh
    Dec 5, 2004
  3. Janet Collins
    Replies:
    0
    Views:
    1,145
    Janet Collins
    Jan 13, 2006
  4. Kim Søvsø Pedersen

    Datalist SelectedItemTemplate problem

    Kim Søvsø Pedersen, Oct 19, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    363
    Kim Søvsø Pedersen
    Oct 19, 2005
  5. yelipolok
    Replies:
    4
    Views:
    255
    John W. Krahn
    Jan 27, 2010
Loading...

Share This Page