Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在CheckChange事件上获取标签文本值_C#_Asp.net_.net_Event Handling - Fatal编程技术网

C# 如何在CheckChange事件上获取标签文本值

C# 如何在CheckChange事件上获取标签文本值,c#,asp.net,.net,event-handling,C#,Asp.net,.net,Event Handling,我试图在复选框的CheckChange事件上获取标签文本。我的复选框更改事件处理程序是: protected void chk_selector_CheckedChanged(object sender, EventArgs e) { } 我的标签是: <asp:TemplateField HeaderText="Title"> <ItemTemplate> <a href="

我试图在复选框的
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>
试试这个

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

投反对票的原因:(
CheckBox chk = (CheckBox)sender; 
GridViewRow gr = (GridViewRow)chk.Parent.Parent;
var lbl = (Label) gr.FindControl("lblTitle");  
if(lbl !=null)
{          
    var lblText = lbl.Text;
}