1

我想通过 id 在我的 gridview.Template 详细信息行中找到控件

        bool IsAllAud = false;
        var item = (CheckBox)VendorsGrid.Templates.DetailRow.FindControl("CBIsAllAudience");
        IsAllAud = item.Checked;
        if (IsAllAud)
        {

        }
<dx:ASPxGridView ID="rt" ClientInstanceName="rt" runat="server"
            AutoGenerateColumns="false" DataSourceID="rtt" KeyFieldName="ID" Width="100%">
            <SettingsDetail AllowOnlyOneMasterRowExpanded="true" />
            <Columns>
                <dx:GridViewDataTextColumn FieldName="Name" Caption="Name" />
            </Columns>
            <Templates>
                <DetailRow>
                    <asp:CheckBox ID="CBIsAllAudience" runat="server" />
...
4

2 回答 2

2

由于这是 DetailRow,您需要调用ASPxGridView.FindDetailRowTemplateControl 方法

var item = VendorsGrid.FindDetailRowTemplateControl(index, "CBIsAllAudience");

于 2012-04-18T15:02:42.477 回答
2

在控制事件中只写这段代码

{
 for (int i = 0; i < gvVndInvoiceDevExp.VisibleRowCount ; i++)
            {
                GridViewDataColumn col1 = gvVndInvoiceDevExp.Columns[0] as GridViewDataColumn;
                GridViewDataColumn col2 = gvVndInvoiceDevExp.Columns[8] as GridViewDataColumn;
                CheckBox chk = gvVndInvoiceDevExp.FindRowCellTemplateControl(i, col1, "chk") as CheckBox;
                ASPxCheckBox chkIsVal = gvVndInvoiceDevExp.FindRowCellTemplateControl(i, col2, "chkIsVal") as ASPxCheckBox;

                if (chk.Checked == true)
                {
                    chkIsVal.Enabled = true;

                }
                else
                {
                    chkIsVal.Enabled = false;

                }

            }
}
于 2012-12-05T07:08:17.677 回答