473,569 Members | 2,526 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 2017

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

Similar topics

0
1920
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 the data from my DB. Works great, except I have <asp:LinkButtons in the cells that perform some operation on the server. Here is the big problem. ...
4
3926
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 the element outside of the table and then using cut & paste in HTML View to move it to the desired location, or by manually typing the code in using...
2
1430
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
2029
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
1530
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 runat="server" ID="HARS_Table" > <asp:TableRow><asp:TableCell><p>Average weekly Inbound calls offered
2
2371
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 consists of an asp table called MyTable containing a textbox control call MyTextBox then i can access MyTextBox directly from the PageLoad event...
0
1074
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
5518
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 server side, I assume we cannot use excel automation based on the license agreement. What would b the best way to do that? Any help would be...
0
1090
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 the top of the page: <% Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment;...
6
1716
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 works fine if I just display in the page "<%=myImageFileName%>", but the server control doesn't recognize it. Is it a miscrosoft bug or did I got...
0
7700
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.