Repeater control Hyperlink to Search data from Database URLs

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
I am using Visual studio 2005 and Sql server 2005.
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small I have created a Repeater control that displays information about Employee contained in a SQL database. In Repeater control it display the name
of the employee but i want to when user click on Name It will display Complete information about employee.

<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small My code is:-
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small using System.Data.SqlClient;
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small public partial class Search : System.Web.UI.Page
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px {
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px protected void Page_Load(object sender, EventArgs e)
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px {
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px if (Request.QueryString["searchString"] != null)
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px {
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px DisplaySearchResults(Request.QueryString["searchString"]);
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px }
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px }
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small public void DisplaySearchResults(string strSearch)
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px {
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px //SqlCommand cmd = new SqlCommand("spSearchByString", new SqlConnection(ConfigurationManager.AppSettings["RegpConnectionString"]));
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px //cmd.CommandType = CommandType.StoredProcedure;
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small SqlConnection con = new SqlConnection();
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px string Mycon = ConfigurationManager.ConnectionStrings["MyConsString"].ConnectionString;
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px con = new SqlConnection(Mycon);
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px SqlCommand cmd = new SqlCommand("spSearchByString", con);
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px cmd.CommandType = CommandType.StoredProcedure;
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small cmd.Parameters.AddWithValue("@SearchString", strSearch);
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px //cmd.Connection.Open();
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px con.Open();
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small Repeater1.DataSource = cmd.ExecuteReader();
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px Repeater1.DataBind();
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small //cmd.Connection.Close();
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px //cmd.Connection.Dispose();
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px con.Close();
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px }
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small protected void Button1_Click(object sender, EventArgs e)
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px {
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px Response.Redirect("Search.aspx?searchString=" + Server.UrlEncode(TextBox1.Text));
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px }
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px }
<div style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small

<div style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small

<div style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small

<div style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small

<div style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small
and design code is
<div style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small

<div style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small


<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:xx-small <span style="line-height:16px <br/>

<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <body>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small <br />
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px &nbsp;<br />
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <table align="center" bgcolor="#5482fc" border="0" cellpadding="5" cellspacing="1"
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px style="position: static; width: 692px;
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <tr>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <td align="center" class="lgHeader1" height="50
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px Search Database with String </td>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px </tr>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px </table>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <br />
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <br />
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <fieldset style="width: 804px" align="center
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <legend>Search Database with String</legend>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <div align="left" style="text-align: center
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small <form id="form1" runat="server This form will search for matching First Names and Last Name within the database.<br />
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px Search: <asp:TextBox ID="TextBox1" runat="server </asp:TextBox><br />
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" /><br /><br
/>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <asp:Repeater ID="Repeater1" runat="server
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <HeaderTemplate><table width="100%" align="left <tr align="left <th>First Name</th><%--<th>Last
Name</th>--%></tr></HeaderTemplate>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <ItemTemplate>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <tr align="left <td>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <%#DataBinder.Eval(Container.DataItem, "Fname")%> </td>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <%-- <td><%#DataBinder.Eval(Container.DataItem, "Lname")%></td></tr>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px --%> </ItemTemplate>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <FooterTemplate></table></FooterTemplate>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px </asp:Repeater>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px </form>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:x-small
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px </fieldset>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px </body>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px </html>
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px

<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px Please help me
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px Regard
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px
<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <br/>

<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <br/>

<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <br/>

<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <br/>

<span style="color:#313c46; font-family:Arial,Helvetica,sans-serif; font-size:x-small <span style="line-height:16px <br/>

<div style="color:#313c46; font-family:Arial,Helvetica,sans-serif; line-height:16px; font-size:small



<
Ramesh<br/>

View the full article
 
Back
Top