.Net with C#. Iv'e created a repeater control in my ASPX and bind it from C#. I want to use the click event of the button for that, if the user clicks the button it shows the values of the row in the database.

In the repeater I bind the username from a database table. If the user clicks on the username it should display the user details in a label outside the repeater.

Code of the repeater control:

<asp:Repeater ID="rpt3" runat="server">
        <h3>   <%#Eval("name") %>  </h3>
        <asp:Button ID="Button1" runat="server" Text="Show Details"/> 

<asp:Label ID="Label1" runat="server" ></asp:Label>

C# code behind

public void Getuser()
    using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))

        SqlCommand cmd = new SqlCommand("select name from message  where emailid= '" + Session["un"].ToString() + "'", con);
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);

        if (dt.Rows.Count > 0 && dt.Rows[0][0] != string.Empty)
            rpt3.DataSource = dt;
            rpt3.DataSource = null;

Design that i want

0 Answers