Creating Dropdown list control from Datasource
We will create a custom dropdown conrol using a datasource. This code provides us to fill a dropdrown list using a datasource. This code also displays us ASP.NET is easier than classical ASP to generate custom controls. Do not forget to modify database connection and your sql statement. <%@ Page Language="VB" Debug="true" %> Sub Page_Load(Source as Object, E as EventArgs) Dim objCon As OleDBConnection objAdapter.Fill(ds) catList.DataSource=ds.tables(0).DefaultView <form runat="server">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script language="VB" runat="server">
objCon = New OleDBConnection("Provider=sqloledb;Data Source=LOCALHOST;Initial catalog=northwind;User Id=sa;Password=;")
Dim ds as new DataSet
Dim objAdapter As OleDBDataAdapter = New OleDBDataAdapter("Select * from categories order by categoryID desc", objCon)
catList.DataValueField="categoryID"
catList.DataTextField="categoryName"
catList.DataBind()
end sub
</script>
<html><body>
<asp:DropDownList id="catlist" runat="server"/>
</form>
</body></html>
- How to Refresh a web page or redirect to another page
- Custom Paging in ASP Fast And Easy
- Professional Contact Form
- Creating Access Database Connection String
- Using DateDiff function in SQL Statement
- VBScript Examples DatePart Function
- Executing Transact SQL UPDATE statement using SQLCommand
- Custom Paging results in ASPNET using A Better Way
- Sending Emails in JSP
- MySQL AB Offers its Enterprise Database Subscriptions through the New Red Hat Exchange
- Display Top N records from MS Access
- How to display date time in real time
- JSP Hit Counter Free Open Code
- ASP Ikon Ad Manager UPDATED
- Exporting Data From mySQL to Excel
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- What is Ecommerce and the Importance of Ecommerce
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- Counting records in PHP mySQL
- ActiveNews Manager Freeware News Exchange Software
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- ActiveNews Manager Freeware News Exchange Software
- Counting records in PHP mySQL
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Comparing Dates