-1

我正在尝试在复选框的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);
4

1 回答 1

3

尝试这个

CheckBox chk = (CheckBox)sender; 
GridViewRow gr = (GridViewRow)chk.Parent.Parent;
var lbl = (Label) gr.FindControl("lblTitle");  
if(lbl !=null)
{          
    var lblText = lbl.Text;
}
于 2013-08-12T13:35:54.103 回答