我希望通过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" />
...
答案 0 :(得分:2)
由于这是DetailRow,您需要致电ASPxGridView.FindDetailRowTemplateControl Method
var item = VendorsGrid.FindDetailRowTemplateControl(index,“CBIsAllAudience”);
答案 1 :(得分: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;
}
}
}