<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<asp:DataList ID="DataList1" runat="server">
</asp:DataList>
</div>
<asp:Repeater ID="Repeater1" runat="server"
onitemcommand="Repeater1_ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CommandName="cmd" runat="server" Text='<%#Eval("name") %>'>LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
<!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>
<asp:DataList ID="DataList1" runat="server">
</asp:DataList>
</div>
<asp:Repeater ID="Repeater1" runat="server"
onitemcommand="Repeater1_ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CommandName="cmd" runat="server" Text='<%#Eval("name") %>'>LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
..............................................
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"server=COMTECH-PC\SQLEXPRESS;database=ShriGaneshayNamah;integrated security=true;");
protected void Page_Load(object sender, EventArgs e)
{
string str = "select * from employee";
SqlDataAdapter da = new SqlDataAdapter(str,con);
DataSet ds = new DataSet();
da.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if(e.CommandName=="cmd")
{
LinkButton lnk = (LinkButton)e.Item.FindControl("LinkButton1");
string name = lnk.Text;
if(name=="kul")
{
Response.Redirect("https://www.google.co.in/?gfe_rd=cr&ei=vlqFVr78G6fR8AfnlJ_wAQ&gws_rd=ssl");
}
else if(name=="raj")
{
Response.Redirect("https://www.facebook.com/");
}
}
}
}
No comments:
Post a Comment