Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my page I have a 2 list boxes, a Fileupload control and a Display button.

I have to follow the below actions:

1. If I select a value "Get from DB" in listBox1 then the data will be fetched from DB Table and shown in a gridview.
-- This is happening.
2. If I select a value "upload" in listBox1 then the Fileupload control should be enabled.
-- This is also happening.

3. When I upload an excel file in the file upload control and click on display, The list of sheet names in the excel file should be displayed in ListBox2.
-- This is also happening.

4. When I select any sheet name in the list box 2, the data should be read from the selected sheet name of the workbook and get displayed as grid.

-- The issue is in this step only, whatever sheet I select it is automatically selecting the Index 0 and the data from the sheet name at index 0 is getting displayed in the grid view.

To be more clear whatever sheet name I select the sheet name at Index 0 of the list box is considered.

Please help.


Thanks & Regards,
Mathi.
Posted
Comments
Afzaal Ahmad Zeeshan 26-Dec-14 6:45am    
Please share the code, that is required in order to help you out.
Praveen Kumar Upadhyay 26-Dec-14 6:47am    
Code require to check.
deepankarbhatnagar 26-Dec-14 7:42am    
Please share the code first.

Check this. It should work-

C#
string text_value = listBox2.GetItemText(listBox2.SelectedItem);


If this is not working, please let me know :)
 
Share this answer
 
I have found the solution.

I'm using ListBox2.SelectedItem.Text to fetch the value.
But while assigning the DataFieldValue I have given 0 by default for all the List Items.
So whatever I select it considers based on the DataFieldValue, since Item in Index 0 is also having the DataFieldVlaue as 0 whatever Item I select by default it is considering the Item at Index 0.

Solution: Just bound the list alone as ListBox2.DataSource and didnt mention explicitly abount any DataFieldValue.

Thanks all.

Regards,
Mathi.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900