开发者

Get the value of columns on Check_changed Event of checkbox in gridview

I have a grid view which contains date and time string in dataBound field and check box in item template field. Now when user check any check box, i want to make isChecked field of my data table(Which is data source for gridview and isCheck is added programatically) true/false accourdingly. How can I get date time string from gridview based on th开发者_运维百科e check box checked/uncheked??


You can do like...

<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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜