Click here to Skip to main content
15,066,326 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how to store multiple rows in a table from gridview Pin
Tej Aj16-Apr-10 2:50
MemberTej Aj16-Apr-10 2:50 
QuestionReport Viewer Control Pin
Paul Unsworth9-Apr-10 0:26
MemberPaul Unsworth9-Apr-10 0:26 
QuestionGetting response from aspx page Pin
Pryabu8-Apr-10 21:49
MemberPryabu8-Apr-10 21:49 
QuestionASP.Net vs MVC Pin
swjam8-Apr-10 20:15
Memberswjam8-Apr-10 20:15 
AnswerRe: ASP.Net vs MVC Pin
Gaurav Dudeja India8-Apr-10 20:27
MemberGaurav Dudeja India8-Apr-10 20:27 
AnswerRe: ASP.Net vs MVC Pin
sashidhar8-Apr-10 20:55
Membersashidhar8-Apr-10 20:55 
AnswerRe: ASP.Net vs MVC Pin
Brij8-Apr-10 23:56
mentorBrij8-Apr-10 23:56 
QuestionListBox SelectedIndex does not persist during postback [modified] Pin
Toni788-Apr-10 4:49
MemberToni788-Apr-10 4:49 
I have created a custom user control using Visual Studio 2008. The user enters data in three TextBoxes. The data is added in a DataTable which is bound to a ListBox. The user has the option of deleting items from the ListBox.

The ListBox is declared as follows:

asp:ListBox ID="lstNames" runat="server" Height="99px" Width="245px" 
                EnableViewState="True" 
                onselectedindexchanged="lstNames_OnSelectedIndex"></asp:ListBox


Inside the function Page_Load I have the following"
if (!Page.IsPostBack)
{
...
   lstNames.DataSource = table;
   lstNames.DataTextField = "Display";
   lstNames.DataBind();
...
}


I also have two buttons which allow me to add user input from TextBox controls to the ListBox and delete items.

My question is:

When I select an item and try to delete it, the SelecteIndex becomes 0 during the postback and the first item is removed (not the one I select). Basically, the SelectedIndex does not persist during a postback. I have looked at different postings here and other sites as well, searched MSDN but I cannot figure out the answer. Is there a way to overcome this problem and how?

Thanks!
Time is the fire in which we burn.

AnswerRe: ListBox SelectedIndex does not persist during postback Pin
JHizzle8-Apr-10 5:03
MemberJHizzle8-Apr-10 5:03 
GeneralRe: ListBox SelectedIndex does not persist during postback Pin
Toni788-Apr-10 5:18
MemberToni788-Apr-10 5:18 
GeneralRe: ListBox SelectedIndex does not persist during postback Pin
JHizzle8-Apr-10 5:26
MemberJHizzle8-Apr-10 5:26 
GeneralRe: ListBox SelectedIndex does not persist during postback [modified] Pin
Toni788-Apr-10 8:03
MemberToni788-Apr-10 8:03 
AnswerRe: ListBox SelectedIndex does not persist during postback Pin
michaelschmitt8-Apr-10 8:42
Membermichaelschmitt8-Apr-10 8:42 
GeneralRe: ListBox SelectedIndex does not persist during postback Pin
Toni788-Apr-10 8:56
MemberToni788-Apr-10 8:56 
QuestionMultiple file upload Pin
paper678-Apr-10 4:13
Memberpaper678-Apr-10 4:13 
AnswerRe: Multiple file upload Pin
chriswk8-Apr-10 19:21
Memberchriswk8-Apr-10 19:21 
GeneralRe: Multiple file upload Pin
Gaurav Dudeja India8-Apr-10 19:31
MemberGaurav Dudeja India8-Apr-10 19:31 
GeneralRe: Multiple file upload Pin
paper679-Apr-10 5:08
Memberpaper679-Apr-10 5:08 
AnswerRe: Multiple file upload Pin
Anurag Gandhi8-Apr-10 19:33
professionalAnurag Gandhi8-Apr-10 19:33 
QuestionHow to Block Specific IP Number to Access my website Pin
Samarjeet Singh@india8-Apr-10 2:26
MemberSamarjeet Singh@india8-Apr-10 2:26 
AnswerRe: How to Block Specific IP Number to Access my website Pin
Brij8-Apr-10 3:46
mentorBrij8-Apr-10 3:46 
AnswerRe: How to Block Specific IP Number to Access my website Pin
Jens Meyer8-Apr-10 3:51
MemberJens Meyer8-Apr-10 3:51 
GeneralRe: How to Block Specific IP Number to Access my website Pin
Brij8-Apr-10 7:28
mentorBrij8-Apr-10 7:28 
AnswerRe: How to Block Specific IP Number to Access my website Pin
Abhijit Jana8-Apr-10 8:51
professionalAbhijit Jana8-Apr-10 8:51 
QuestionSession Pin
Morgs Morgan8-Apr-10 2:25
MemberMorgs Morgan8-Apr-10 2:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.