HOW DATALIST BIND IN ASP.NET WITHOUT C# CODING

K011gusain89
Posted by K011gusain89 under ASP.NET category on | Points: 40 | Views : 2828
CREATE CONNECTION STRING IN WEB Config FILE..
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="DATAConnectionString " connectionString="Data Source=LOCAL-PC;Initial Catalog=kuldeep;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

Create a table name tb_sign_up and co;umn is
first_name, last_name, email, password, gender,date_of_birth

<!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 id="Head1" runat="server">
<title>Simple List</title>
</head>
<body>
<form id="form1" runat="server">
<div> <h2 style="color: Green">DataList in ASP.NET using C#</h2>
<asp:DataList ID="DataListExample" runat="server" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="5" CellSpacing="12"
DataSourceID="SqlDataSource1" Font-Bold="True" Font-Names="Verdana" Font-Size="Small" GridLines="Both" RepeatColumns="2" RepeatDirection="Vertical"
Width="1181px" Height="269px" oneditcommand="DataListExample_EditCommand">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" Font-Size="Large" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderTemplate>Student Information</HeaderTemplate>
<FooterTemplate>this is footer</FooterTemplate>
<ItemStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<ItemTemplate>
id:<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("id") %>' ForeColor="#000099" /><br />
First Name:<asp:Label ID="DOBLabel" runat="server" Text='<%# Eval("first_name") %>' /><br />
Last Name:<asp:Label ID="AgeLabel" runat="server" Text='<%# Eval("last_name") %>' /><br />
Email:<asp:Label ID="CourseLabel" runat="server" Text='<%# Eval("email") %>' /><br />
password:<asp:Label ID="BranchLabel" runat="server" Text='<%# Eval("password") %>' /><br />
Gender:<asp:Label ID="CityLabel" runat="server" Text='<%# Eval("gender") %>' /><br />
DOB:
<asp:Label ID="MobileNoLabel" runat="server" Text='<%# Eval("date_of_birth") %>' /><br />
</ItemTemplate>
<EditItemTemplate><asp:TextBox ID="a" runat="server" Text='<%# Eval("email") %>'></asp:TextBox></EditItemTemplate>
<SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DATAConnectionString %>"
SelectCommand="SELECT * FROM [tb_sign_up]" ></asp:SqlDataSource>
</div>
</form> </body> </html>

Comments or Responses

Posted by: Dalbir on: 10/23/2012 Level:Starter | Status: [Member] | Points: 10
Simple,
u can use VB instead of C#

Login to post response