Introduction
i will explain How to add item to ListBox by AccessDataSource in asp.net.
Description ASP.NET ListBox & DataBinding ListBox is used to read data from AccessDataSource.
Example
<%@
page language="C#" autoeventwireup="true" codefile="How-to-additem-ListBox-c.aspx.cs"
inherits="How_to_additem_ListBox_c"
%>
<!DOCTYPE
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head
runat="server">
<title>How to
add item to ListBox by AccessDataSource</title>
</head>
<body>
<form id="form1"
runat="server">
<div>
<asp:accessdatasource id="AccessDataSource1" runat="server" datafile="~/App_Data/Northwind.mdb"
selectcommand="SELECT * FROM [Categories]">
</asp:accessdatasource> <br /> <br /> <asp:listbox id="ListBox1" runat="server" datasourceid="AccessDataSource1" datatextfield="CategoryName" datavaluefield="CategoryName" height="162px" width="371px"></asp:listbox>
</div>
</form>
</body>
</html>
|
0 comments :
Post a Comment