Click here to Skip to main content
15,905,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<%@ 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:Repeater ID="rptrTable" runat="server"
            onitemcommand="rptrTable_ItemCommand" >

        <HeaderTemplate>
        <table border=3>
        <tr>
        <th>Agent ID</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>City</th>
        <th>SSN</th>
        </tr>

        </HeaderTemplate>
        <ItemTemplate>
        <tr>
        <td>
        <%# DataBinder.Eval(Container.DataItem,"AgentID") %>
        </td>
        <td>
        <%# DataBinder.Eval(Container.DataItem,"FirstName") %>
        </td>
        <td>
        <%# DataBinder.Eval(Container.DataItem,"LastName") %>
        </td>
        <td>
        <%# DataBinder.Eval(Container.DataItem,"City") %>
        </td>
        <td>
        <%# DataBinder.Eval(Container.DataItem,"SSN") %>
        </td>

        <td>
            <asp:Button ID="btnShow" runat="server" Text="Show" CommandName="ShowButt" CommandArgument='<%# Eval("AgentID") %>' />
        </td>
        <td>
            <asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="EditButt" />
        </td>

        </tr>
        </ItemTemplate>
        </asp:Repeater>
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>



my .cs file is

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    SqlConnection connection;
    SqlCommand command;
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            string strcon = ConfigurationManager.ConnectionStrings["AgentConn"].ConnectionString;
            connection = new SqlConnection(strcon);
            command = new SqlCommand("prcAgentShow", connection);
            command.CommandType = CommandType.StoredProcedure;
            connection.Open();
            DataTable dt = new DataTable();
            SqlDataReader dataReader = command.ExecuteReader();
            dt.Load(dataReader);
            rptrTable.DataSource = dt;
            rptrTable.DataBind();
        }
    }
   
        
        protected void rptrTable_ItemCommand(object source, RepeaterCommandEventArgs e)
         {
        if (e.CommandName.Equals("ShowButt"))
        {
            Label1.Text = "u clik the show button ";
        }
        
    }
}


from sorce file button show having AgentID THAT SHOULD RETURN TO LABEL1 HOW ?
HOW PLEASE HELP
Posted
Updated 23-Jan-12 3:10am
v2

1 solution

try this

C#
protected void rptrTable_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
       if (e.CommandName == "ShowButt")
            {
              Label1.Text = e.CommandArgument.ToString();
            }

        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900