Repeator
on page behind-----:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowDetailsInRepeater.aspx.cs" Inherits="GarageDetails.ShowDetailsInRepeater" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
`<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<asp:Label ID="lblRepFirstName" runat="server" Text="Enter The Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtRepFirstName" runat="server"
ontextchanged="txtRepFirstName_TextChanged">
</asp:TextBox>
</td>
</tr>
<asp:Repeater id="GetGarageDetails" runat="server"
>
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>CustomerId</th>
<th>FirstName</th>
<th>LastName</th>
<th>ContactNumber</th>
<th>VehicleName</th>
<th>ChesisNumber</th>
<th>EngineNumber</th>
<th>RegistrationNumber</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lblCustomerId" runat="server" Text='<%# Eval("CustomerId") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblFirstName" runat="server" Text='<%#Eval("FirstName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblLastName" runat="server" Text='<%#Eval("LastName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblContactNumber" runat="server" Text='<%#Eval("ContactNumber") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblVehicleName" runat="server" Text='<%#Eval("VehicleName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblEngineNumber" runat="server" Text='<%#Eval("EngineNumber") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblChesisNumber" runat="server" Text='<%#Eval("ChesisNumber") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblRegistrationNumber" runat="server" Text='<%#Eval("RegistrationNumber") %>'></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</table>
</center>
</div>
</form>
</body>
</html>
---------------------------------------
OR
Grid
Page Behing Code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="grid.aspx.cs" Inherits="VehicleManagementSystem.grid" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Label ID="lblName" runat="server" Text="Enter the name to be searched"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtName" runat="server" ontextchanged="txtName_TextChanged" AutoPostBack="true"></asp:TextBox>
</td>
</tr>
</table>
<asp:GridView ID="GridForData" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="OwnerId" HeaderText="OwnerId"/>
<asp:BoundField DataField="OwnerFirstName" HeaderText="FirstName"/>
<asp:BoundField DataField="OwnerMiddleName" HeaderText="MiddleName"/>
<asp:BoundField DataField="OwnerLastName" HeaderText="LastName" />
<asp:BoundField DataField="VehicalName" HeaderText="VehicalName"/>
<asp:BoundField DataField="VehicalNo" HeaderText="VehicalNo"/>
<asp:BoundField DataField="ChechisNo" HeaderText="ChechisNo"/>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
on page behind-----:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowDetailsInRepeater.aspx.cs" Inherits="GarageDetails.ShowDetailsInRepeater" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
`<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<asp:Label ID="lblRepFirstName" runat="server" Text="Enter The Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtRepFirstName" runat="server"
ontextchanged="txtRepFirstName_TextChanged">
</asp:TextBox>
</td>
</tr>
<asp:Repeater id="GetGarageDetails" runat="server"
>
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>CustomerId</th>
<th>FirstName</th>
<th>LastName</th>
<th>ContactNumber</th>
<th>VehicleName</th>
<th>ChesisNumber</th>
<th>EngineNumber</th>
<th>RegistrationNumber</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lblCustomerId" runat="server" Text='<%# Eval("CustomerId") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblFirstName" runat="server" Text='<%#Eval("FirstName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblLastName" runat="server" Text='<%#Eval("LastName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblContactNumber" runat="server" Text='<%#Eval("ContactNumber") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblVehicleName" runat="server" Text='<%#Eval("VehicleName") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblEngineNumber" runat="server" Text='<%#Eval("EngineNumber") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblChesisNumber" runat="server" Text='<%#Eval("ChesisNumber") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblRegistrationNumber" runat="server" Text='<%#Eval("RegistrationNumber") %>'></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</table>
</center>
</div>
</form>
</body>
</html>
---------------------------------------
OR
Grid
Page Behing Code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="grid.aspx.cs" Inherits="VehicleManagementSystem.grid" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Label ID="lblName" runat="server" Text="Enter the name to be searched"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtName" runat="server" ontextchanged="txtName_TextChanged" AutoPostBack="true"></asp:TextBox>
</td>
</tr>
</table>
<asp:GridView ID="GridForData" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="OwnerId" HeaderText="OwnerId"/>
<asp:BoundField DataField="OwnerFirstName" HeaderText="FirstName"/>
<asp:BoundField DataField="OwnerMiddleName" HeaderText="MiddleName"/>
<asp:BoundField DataField="OwnerLastName" HeaderText="LastName" />
<asp:BoundField DataField="VehicalName" HeaderText="VehicalName"/>
<asp:BoundField DataField="VehicalNo" HeaderText="VehicalNo"/>
<asp:BoundField DataField="ChechisNo" HeaderText="ChechisNo"/>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
-----------------------------------------
DAL Page :-
public DataTable GetOwnerDetailsForGridview(string OwnerFirstName)
{
SqlConnection con = new SqlConnection(Setting.ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_GetOwnerDetailsForGridview";
cmd.Parameters.AddWithValue("OwnerFirstName", OwnerFirstName);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
DataTable dt = ds.Tables[0];
return dt;
}
---------------------------------
ON Page:-
protected void txtOwnersFirstName_TextChanged(object sender, EventArgs e)
{
string OwnerFirstName = txtOwnersFirstName.Text;
VehicalDetailsDAL vehicalsDetailsDAL = new VehicalDetailsDAL();
RepeaterForData.DataSource = vehicalsDetailsDAL.GetOwnerDetailsForGridview(OwnerFirstName);
RepeaterForData.DataBind();
}
No comments:
Post a Comment