0% found this document useful (0 votes)
21 views4 pages

Date: Create Web Application Which Use Data Controls Like Repeater, Datalist, Datagrid Ex: 10

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

Date: Create Web Application Which Use Data Controls Like Repeater, Datalist, Datagrid Ex: 10

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Date:

Create web application which use data controls like Repeater, DataList,
Ex: 10 DataGrid

Enrollment No: 92210103022 Name: Namrata Solanki Class & Batch: 6TC6-C

Source Code:
WebForm1.aspx

<%@ flage Language="C " AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"


Inherits="flrac10.WebForm1" %>

<!DOCTYflE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DATA CO TROLS - flractical 10</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div style="font-size:x-large" align="center">DATA CO TROLS</div>
<br />
<table class="w-100">
<tr>
<td style="width: 190px">finbsp;</td>
<td>Repeater</td>
</tr>
<tr>
<td style="width: 190px">finbsp;</td>
<td>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<table>
<tr>
<td><b> ID :</b> </td>
<th><% Eval("id") %></th>
</tr>
<tr>
<td><b> ame :</b></td>
<th><% Eval("name") %></th>
</tr>
<tr>
<td><b> EMAIL :</b> </td>
<th><% Eval("email") %></th>
</tr>
<tr>
<td><b> CO TACT :</b></td>
<th><% Eval("contact") %></th>
</tr>
</table>
</ItemTemplate>

.NET Technologies Lab (01CE1602)


</asp:Repeater>
</td>
</tr>
<tr>
<td style="width: 190px; height: 30px;"></td>
</tr>
<tr>
<td style="width: 190px">finbsp;</td>
<td>Data List</td>
</tr>
<tr>
<td style="width: 190px">finbsp;</td>
<td>
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<table cellpadding="2" cellspacing="0" border="1"
style="width: 300px; height: 100px; border:dashed 2px 04AFEF; background-
color:blueviolet">
<tr>
<td><b> ID : </b><span class="id"><% Eval("id")
%></span></td>
</tr>
<tr>
<td><b> AME : </b><span class="name"><%
Eval("name") %></span></td>
</tr>
<tr>
<td><b> EMAIL : </b><span class="email"><%
Eval("email") %></span></td>
</tr>
<tr>
<td><b> CO TACT : </b><span class="contact"><%
Eval("contact") %></span></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td style="width: 190px">finbsp;</td>
</tr>
<tr>
<td style="width: 190px">finbsp;</td>
<td>Data Grid</td>
</tr>
<tr>
<td style="width: 190px">finbsp;</td>
<td>
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor=" 999999" BorderStyle="Solid" BorderWidth="1px" Cellfladding="3"
ForeColor="Black" GridLines="Vertical" Width="700px">
<AlternatingRowStyle BackColor=" CCCCCC" />
<FooterStyle BackColor=" CCCCCC" />
< eaderStyle BackColor="Black" Font-Bold="True" ForeColor="White"
/>
<flagerStyle BackColor=" 999999" ForeColor="Black"
orizontalAlign="Center" />

.NET Technologies Lab (01CE1602)


<SelectedRowStyle BackColor=" 000099" Font-Bold="True"
ForeColor="White" />
<SortedAscendingCellStyle BackColor=" F1F1F1" />
<SortedAscending eaderStyle BackColor=" 808080" />
<SortedDescendingCellStyle BackColor=" CAC9C9" />
<SortedDescending eaderStyle BackColor=" 383838" />
</asp:GridView>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

WebForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace flrac10
{
public partial class WebForm1 : System.Web.UI.flage
{
protected void flage_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=LAflTOfl-
76D7BK2K\\SQLEXflRESS;Initial Catalog=Demo;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM demotbl", con);
DataTable rdt = new DataTable();
sda.Fill(rdt);
Repeater1.DataSource = rdt;
Repeater1.DataBind();

SqlDataAdapter sda1 = new SqlDataAdapter("SELECT * FROM demotbl", con);


DataTable ddt = new DataTable();
sda.Fill(ddt);
DataList1.DataSource = ddt;
DataList1.DataBind();

SqlCommand cmd = new SqlCommand("SELECT * FROM demotbl", con);


SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable gdt = new DataTable();
adp.Fill(gdt);
GridView1.DataSource = gdt;
GridView1.DataBind();

}
}
}

.NET Technologies Lab (01CE1602)


Output:

.NET Technologies Lab (01CE1602)

You might also like