首页 > 其他 > 详细

Button获取Repeater一行的两个值

时间:2016-04-23 11:51:12      阅读:306      评论:0      收藏:0      [点我收藏+]

aspx

<asp:Repeater ID="Repeater1" runat="server">
     <ItemTemplate>


     <div style="  width:100%;">
     <span style=" float:left; width:70%;"><%#Eval("Companyname") %> </span>
      <span style=" float:left; width:28%; ">
      <asp:Button ID="Button3" runat="server" Text="选择"  CommandArgument=‘<%#Eval("infoID") %>‘ CommandName=‘<%#Eval("Companyname") %>‘
             onclick="Button3_Click"  /> </span>
    
</div>
     </ItemTemplate>
     </asp:Repeater>

 

<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
 <asp:Label ID="Label2" runat="server" Visible="False"></asp:Label>

 

 

cs

 protected void Button3_Click(object sender, EventArgs e)
    {
        Button btn = sender as Button;
        // int id = int.Parse(btn.CommandArgument);
        string argName = ((Button)sender).CommandName;
        string argArg = ((Button)sender).CommandArgument;

        Label2.Text = argArg;
        Label1.Text = argName;

       

        //DataAccess.Da dac = new DataAccess.Da();
        //dac.con.Open();
        //string sql = "select * from Company_info where infoID =‘" + id + "‘";
        //SqlCommand cmd = new SqlCommand(sql, dac.con);
        //cmd.Connection = dac.con;
        //SqlDataReader sdr = cmd.ExecuteReader();
        //sdr.Read();
        //Label1.Text = sdr["Companyname"].ToString();
      
        //sdr.Close();
        //dac.con.Close();

      

    }

 

Button获取Repeater一行的两个值

原文:http://www.cnblogs.com/huichao1314/p/5424103.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!