473,508 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[Asp.net]:How to populate the drop down lists in Excel sheet from sql server table

12 New Member
How do I create a drop down list which has the values from a database column. So I need this list to have values like"

"Select distinct departmentname from Department"

The Department name should show in the drop down list and I should be able to select one department name from the list.

This is my code for read the column name from an excet test11.xls.now i want to fetch the dataset to that column name departmant.

please help.
Expand|Select|Wrap|Line Numbers
  1. string filePath1 = Server.MapPath("test11.xls");
  2.  
  3. da = new SqlDataAdapter ("select departmentname from departmentmaster", con);
  4. ds = new DataSet();
  5.  
  6. da.Fill(ds);
  7.  
  8.  
  9. DataTable columns;
  10.  
  11. string[] restrictions = { null, null, "Data$", null };
  12.  
  13. //string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
  14. string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath1 + ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;\"";using (OleDbConnection connection = new OleDbConnection(connectionString))
  15.  
  16. {
  17.  
  18. connection.Open();
  19. columns = connection.GetSchema("Columns", restrictions);
  20.  
  21. String[] excelSheets = new String[columns.Rows.Count];
  22. int iwork = 0;
  23.  
  24. // Add the sheet name to the string array.
  25. foreach (DataRow row in columns.Rows)
  26.  
  27. {
  28. excelSheets[iwork] = row["Column_NAME"].ToString();if (excelSheets[iwork] == "Department")
  29.  
  30. {
  31.  
  32. // Here how can i fetch that dataset to the column Department
  33.  
  34.  
  35.  
  36. }
  37.  
  38. iwork++;
  39.  
  40. }
  41.  
  42. }
Oct 25 '08 #1
0 2013

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1908
by: Rich | last post by:
Ok here is what I am doing. I have a <asp:Table object in the html. I am creating the rows and cells dynamically in my codebehind. When I first call the aspx page I create the table based on...
4
3919
by: Nathan Sokalski | last post by:
When editing an ASP Table, Visual Studio does not allow me to edit it in Design View. This makes it harder to add elements, because I must add every element either by using Design View to create...
2
1421
by: ABC | last post by:
How to set VS.NET IDE run ASP.NET server on IIS? Default, ASP.NET project running on ASP.NET Development Server. I don't like it as it very slow slow.
4
2022
by: keithb | last post by:
It looks like the span tag cannot be used with asp tables. What is the best way to make an irregular asp table? Thanks, Keith
1
1527
by: Jon via DotNetMonster.com | last post by:
Hi all, I have a asp.net table control placed on 'Calculator.aspx' page. The table looks like this: <div class="roiHTML" id="highAbandonRateSale" runat="server" visible="false" > <asp:Table...
2
2369
by: clickon | last post by:
I am confused about the way in which asp:table objects work. When a control is within an asp table it generally appears to be in the scope of the tables parent control. E.g. if i have a page that...
0
1072
by: vinayakss | last post by:
in asp.net drop down menu is not working in local machine. but when browsed from other system menu is working fine. i have tried with IE6 and IE7. pl. anybody can reply waht may be the problems.
3
5515
by: Maxwell2006 | last post by:
Hi, We have Excel 2003 templates and we need to automatically generate excel 2003 xls files based on our SQL server database tables' data. Since we need to generate the xls files at out asp.net...
0
1088
blyxx86
by: blyxx86 | last post by:
I was having issues with exporting an ASP table that included images. I have since found a solution for this error, and hope that what I have found becomes useful for some others on this site. At...
6
1711
by: data | last post by:
I searched the internet and saw an old posting which has the same problem I am experiencing. The asp server doesn't recognize the variable I declare publicly in my codebehind class. The variable...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.