如何在CheckChange事件中获取标签文本值



我正在尝试获取复选框的CheckChange事件上的标签文本。我的复选框更改事件处理程序是:

protected void chk_selector_CheckedChanged(object sender, EventArgs e)
{
}

我的标签是:

<asp:TemplateField HeaderText="Title">
                    <ItemTemplate>
                        <a href="javascript:openPopup('Ds_ProjectDetails.aspx?mode=1&cid=<%# Eval("CompanyID") %>&prj=<%#Eval("ProjectID")%>' )">
                            <%--<%#Eval("Title")%>--%>
                            <asp:Label ID="lblTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Label></a>
                    </ItemTemplate>
                    <ControlStyle Width="400px" />
                </asp:TemplateField>

当调用复选框CheckChange事件时,我得到ID:

 CheckBox chk = (CheckBox)sender;        
 GridViewRow gr = (GridViewRow)chk.Parent.Parent;
 bool flag = chk.Checked;
 string EntryID = Convert.ToString(gvProjects.DataKeys[gr.RowIndex].Value);
 con.Update_inv_Proj_Flag(EntryID, flag);

试试这个

CheckBox chk = (CheckBox)sender; 
GridViewRow gr = (GridViewRow)chk.Parent.Parent;
var lbl = (Label) gr.FindControl("lblTitle");  
if(lbl !=null)
{          
    var lblText = lbl.Text;
}

相关内容

  • 没有找到相关文章

最新更新