SelectedItemTemplate is not reflecting in ListView control

Posted by Sheonarayan under Error and Solution on 2/27/2012 | Points: 10 | Views : 3893 | Status : [Administrator] | Replies : 3

I have a ListView with SelectedItemTemplate. In the ItemTemplate I have a LinkButton with CommandName as "Select" that executes OnSelectedIndexChanging event.

The problem
The problem is that when the Select button is clicked for the item that item doesn't appear in the SelectedItemTemplate, when the next Select button of next item is clicked, the previous selected item is displayed into SelectedItemTemplate.

OnSelectedIndexChanging="SelectionChanging"


The solution
The solution of this problem is that we need to set the SelectedIndex of the ListView to the NewSelectedIndex and rebind the data
    protected void SelectionChanging(Object sender, ListViewSelectEventArgs e)
{
ListView1.SelectedIndex = e.NewSelectedIndex;

this.RePopulateData(); // Re populate the data
}


I hope this helps.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com



Responses

Posted by: Ppathi on: 2/27/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for this code.. some days back i had with this issue

Thanks & Regards,
Pasupathi G
No Pain No Gain

Sheonarayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sushantaguha.Net on: 2/27/2012 [Member] Starter | Points: 25

Up
0
Down
Hi, I am sushanta I have to convert a entire content of.aspx page including images, texts into PDF with single button click, how can I do that?
my mail ID is - sushantaguha10@gmail.com




Thanks & regards
Sushanta Guha


Sheonarayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 2/27/2012 [Member] Silver | Points: 25

Up
0
Down


Susant, you can use iTextSharp dll to convert the entire page output to pdf.
In this regard, please refer to the article published by Sheonarayan:
http://www.dotnetfunda.com/articles/article977-pdf-generator-in-net-dynamically-generate-pdf-in-aspnet.aspx

Thanks,
Sanjay

Sheonarayan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response