【问题标题】:Get the value of columns on Check_changed Event of checkbox in gridview获取gridview中复选框的Check_changed事件上的列值
【发布时间】:2011-09-07 13:48:45
【问题描述】:

我有一个网格视图,其中包含数据绑定字段中的日期和时间字符串以及项目模板字段中的复选框。现在,当用户选中任何复选框时,我想使我的数据表的 isChecked 字段(这是 gridview 的数据源,并且 isCheck 以编程方式添加)true/false acourdingly。如何根据选中/未选中的复选框从 gridview 获取日期时间字符串??

【问题讨论】:

  • 您是否在检查/取消检查时进行回发?

标签: c# .net asp.net gridview checkbox


【解决方案1】:

你可以这样做......

<asp:TemplateField HeaderText="Date">
    <ItemTemplate>
      <asp:Label ID="lblDate" runat="server" Text='<%# Eval("Date") %>'></asp:Label>
    </ItemTemplate>
</asp:TemplateField>
     <asp:TemplateField HeaderText="Checkbox">
        <ItemTemplate>
           <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" 
                    oncheckedchanged="CheckBox1_CheckedChanged" />
         </ItemTemplate>
</asp:TemplateField>

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
   String Date = ((Label)((CheckBox)sender).Parent.FindControl("lblDate")).Text;
}

【讨论】:

    猜你喜欢
    • 2011-04-25
    • 1970-01-01
    • 2017-01-16
    • 2010-11-23
    • 1970-01-01
    • 2017-11-03
    • 2012-03-06
    • 1970-01-01
    • 2011-03-02
    相关资源
    最近更新 更多