我有两个网格。它们放在两个更新面板中。
当我从下拉菜单中选择一个项目时,第一个更新面板触发并加载数据。现在工作正常。这是第一个gridview的设计。
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddLocations" />
</Triggers>
<ContentTemplate>
<div class="rounded_corners">
<asp:GridView ID="gridMainCategories" Width="100%" HeaderStyle-BackColor="#3AC0F2"
HeaderStyle-ForeColor="White" RowStyle-BackColor="White" RowStyle-ForeColor="#3A3A3A" runat="server"
AutoGenerateColumns="False" BorderWidth="1px" OnPageIndexChanging="gridMainCategories_PageIndexChanging"
ClientIDMode="Static" ShowHeaderWhenEmpty="True" DataKeyNames="cat_id"
AllowPaging="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton runat="server" ID="rdbSelectedMainCategory" Width="50" GroupName="A" OnCheckedChanged="rdbSelectedMainCategory_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Main Category Id" DataField="cat_id" Visible="false">
</asp:BoundField>
<asp:BoundField HeaderText="Name (Eng)" DataField="cat_name_eng" ReadOnly="true">
<HeaderStyle Width="40%"></HeaderStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Name (Sin)" DataField="cat_name_sin" ReadOnly="true">
<HeaderStyle Width="40%"></HeaderStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Active Status" DataField="cat_active_status" ReadOnly="true">
<HeaderStyle Width="5%"></HeaderStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Order No" DataField="cat_order_no" ReadOnly="true">
<HeaderStyle Width="10%" />
</asp:BoundField>
<asp:CommandField ShowEditButton="True" ButtonType="Image" EditImageUrl="~/images/edit.png" ShowCancelButton="False">
<HeaderStyle Width="100px" />
</asp:CommandField>
</Columns>
<HeaderStyle BackColor="Gray" ForeColor="White" Height="40px"></HeaderStyle>
<RowStyle Height="20px"></RowStyle>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
所以我想要做的是当我选择单选按钮时,我要填充另一个网格视图。我在下面的事件
中编写了代码 protected void rdbSelectedMainCategory_CheckedChanged(object sender, EventArgs e)
{
}
这是我的第二个更新面板,带有第二个网格视图
<asp:UpdatePanel runat="server" ID="upi">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdbSelectedMainCategory" />
</Triggers>
<ContentTemplate>
<div class="rounded_corners">
<asp:GridView ID="gridSubCategory1" Width="100%" HeaderStyle-BackColor="#3AC0F2"
HeaderStyle-ForeColor="White" RowStyle-BackColor="White" RowStyle-ForeColor="#3A3A3A" runat="server"
AutoGenerateColumns="False" BorderWidth="1px" OnPageIndexChanging="gridSubCategory1_PageIndexChanging"
ClientIDMode="Static" ShowHeaderWhenEmpty="True"
AllowPaging="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton runat="server" ID="rdbSelectedSubCategory1" Width="50" GroupName="B" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Main Category Id" DataField="cat_id" Visible="false">
<HeaderStyle Width="5%"></HeaderStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Name (Eng)" DataField="cat_name_eng" ReadOnly="true">
<HeaderStyle Width="40%"></HeaderStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Name (Sin)" DataField="cat_name_sin" ReadOnly="true">
<HeaderStyle Width="40%"></HeaderStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Active Status" DataField="cat_active_status" ReadOnly="true">
<HeaderStyle Width="5%"></HeaderStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Order No" DataField="cat_order_no" ReadOnly="true">
<HeaderStyle Width="10%" />
</asp:BoundField>
<asp:CommandField ShowEditButton="True" ButtonType="Image" EditImageUrl="~/images/edit.png" ShowCancelButton="False">
<HeaderStyle Width="100px" />
</asp:CommandField>
</Columns>
<HeaderStyle BackColor="Gray" ForeColor="White" Height="40px"></HeaderStyle>
<RowStyle Height="20px"></RowStyle>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
精细。但是当我尝试调试这个错误消息显示时,我就是探测器。
在UpdatePanel'upi'中找不到ID为“rdbSelectedMainCategory”的控件。 异常详细信息:System.InvalidOperationException:在UpdatePanel'updi'中找不到触发器ID为“rdbSelectedMainCategory”的控件。
第二个更新面板的触发器无法识别项目模板中的单选按钮。 怎么解决这个?