<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Management.aspx.cs" Inherits="Management" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table width="100%">
<tr>
<td>
<table width="30%" align="left">
<tr>
<td align="left">
<asp:DataList ID="DataList1" Width="80%" runat="server" RepeatColumns="1" OnItemCommand="DataList1_ItemCommand" BackColor="White">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" Text='<%#Eval("Name") %>' CommandName="name" CommandArgument='<%#Eval("Name") %>' runat="server" Font-Size="17px" Font-Bold="true" ForeColor="Black">LinkButton</asp:LinkButton>
<br />
<asp:Label ID="Label2" runat="server" Text='<%#Eval("post") %>'></asp:Label><hr style="border-top-style: solid; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; border-top-width: 1px;" />
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
<table width="70%">
<tr>
<td align="left">
<asp:DataList ID="DataList2" runat="server" Width="100%">
<ItemTemplate>
<table width="100%">
<tr>
<td width="30%">
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("image") %>' />
<br />
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Name") %>' Font-Bold="true" ForeColor="black" ></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text='<%#Eval("post") %>'></asp:Label>
</td>
<td width="70%">
<asp:Label ID="Label3" runat="server" Text='<%#Eval("Description") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Content>
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Configuration;
public partial class Management : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
SqlDataAdapter da;
SqlCommand cmd;
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
datashow1();
//datashow2();
datashow3();
}
public void datashow1()
{
try
{
da = new SqlDataAdapter("select *from management", con);
dt = new DataTable();
da.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
}
catch (Exception)
{
}
}
public void datashow2()
{
try
{
da = new SqlDataAdapter("select top(1) *from management where Name='"+Session["name"].ToString()+"'", con);
dt = new DataTable();
da.Fill(dt);
DataList2.DataSource = dt;
DataList2.DataBind();
}
catch (Exception)
{
}
}
public void datashow3()
{
try
{
da = new SqlDataAdapter("select top(1) *from management", con);
dt = new DataTable();
da.Fill(dt);
DataList2.DataSource = dt;
DataList2.DataBind();
}
catch (Exception)
{
}
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "name")
{
Session["name"]=e.CommandArgument.ToString();
//Response.Redirect("Management.aspx");
datashow2();
}
}
}
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table width="100%">
<tr>
<td>
<table width="30%" align="left">
<tr>
<td align="left">
<asp:DataList ID="DataList1" Width="80%" runat="server" RepeatColumns="1" OnItemCommand="DataList1_ItemCommand" BackColor="White">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" Text='<%#Eval("Name") %>' CommandName="name" CommandArgument='<%#Eval("Name") %>' runat="server" Font-Size="17px" Font-Bold="true" ForeColor="Black">LinkButton</asp:LinkButton>
<br />
<asp:Label ID="Label2" runat="server" Text='<%#Eval("post") %>'></asp:Label><hr style="border-top-style: solid; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; border-top-width: 1px;" />
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
<table width="70%">
<tr>
<td align="left">
<asp:DataList ID="DataList2" runat="server" Width="100%">
<ItemTemplate>
<table width="100%">
<tr>
<td width="30%">
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("image") %>' />
<br />
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Name") %>' Font-Bold="true" ForeColor="black" ></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text='<%#Eval("post") %>'></asp:Label>
</td>
<td width="70%">
<asp:Label ID="Label3" runat="server" Text='<%#Eval("Description") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Content>
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Configuration;
public partial class Management : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
SqlDataAdapter da;
SqlCommand cmd;
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
datashow1();
//datashow2();
datashow3();
}
public void datashow1()
{
try
{
da = new SqlDataAdapter("select *from management", con);
dt = new DataTable();
da.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
}
catch (Exception)
{
}
}
public void datashow2()
{
try
{
da = new SqlDataAdapter("select top(1) *from management where Name='"+Session["name"].ToString()+"'", con);
dt = new DataTable();
da.Fill(dt);
DataList2.DataSource = dt;
DataList2.DataBind();
}
catch (Exception)
{
}
}
public void datashow3()
{
try
{
da = new SqlDataAdapter("select top(1) *from management", con);
dt = new DataTable();
da.Fill(dt);
DataList2.DataSource = dt;
DataList2.DataBind();
}
catch (Exception)
{
}
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "name")
{
Session["name"]=e.CommandArgument.ToString();
//Response.Redirect("Management.aspx");
datashow2();
}
}
}
No comments:
Post a Comment