从gridview内的单选按钮触发异步回调

时间:2017-01-09 14:13:46

标签: asynchronous c#-4.0 callback radio-button

我有一个gridview,其中一列包含单选按钮。我放在项目模板中。我想触发异步回调到我有一个网格的面板。这个完整的页面是一个用户控件。

当我无法添加触发器时

<asp:GridView ID="grdBalStatus" runat="server" AutoGenerateColumns="false" Width="100%">
                    <HeaderStyle CssClass="dlresultheader" />
                    <RowStyle CssClass="griditems" />
                    <Columns>
                        <asp:BoundField DataField="TerminalId" HeaderStyle-Width="35%" />
                        <asp:BoundField DataField="Description"></asp:BoundField>
                        <asp:TemplateField HeaderStyle-Width="65%" HeaderText="Auto/Full Balancing Status">
                            <HeaderTemplate>
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td align="right" style="width: 32%">
                                            <%--<asp:Label ID="lblSelAll" runat="server" CssClass="autoresultheader" Text="All:"></asp:Label>--%>
                                        </td>
                                        <td align="left" style="width: 60%">
                                            <asp:RadioButton ID="rdAllAuto" runat="server" CssClass="autoresultheader" GroupName="AutoorFull1"
                                                Text="Auto" ToolTip="Select auto balancing for all Self-Checkouts" />
                                            <asp:RadioButton ID="rdAllFull" runat="server" CssClass="autoresultheader" GroupName="AutoorFull1"
                                                Text="Full" ToolTip="Select full balancing for all Self-Checkouts" />

                                        </td>
                                        <td style="width: 8%">&nbsp;
                                        </td>
                                    </tr>
                                </table>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td align="right" style="width: 32%">
                                            <asp:Label runat="server" ID="TermId" Text='<%# Eval("TerminalId") %>' CssClass="hide"></asp:Label>
                                        </td>
                                        <td align="left" style="width: 60%">
                                            <asp:RadioButton ID="rdAuto" runat="server" CssClass="fullgriditems" GroupName="AutoorFull"
                                                Text="Auto" />
                                            <asp:RadioButton ID="rdFull" runat="server" CssClass="fullgriditems" GroupName="AutoorFull"
                                                AutoPostBack="true" OnCheckedChanged="rdFull_CheckedChanged" Text="Full" />
                                        </td>
                                        <td style="width: 8%">
                                            <%--<asp:Label runat="server" ID="Version" Text='<%# Eval("TerminalVersion") %>' CssClass="hide"></asp:Label>      --%>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="TerminalVersion"></asp:BoundField>
                    </Columns>
                </asp:GridView>

更新面板中的代码

<asp:UpdatePanel ID="upFullBalTerm" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
            <Triggers> 
                <asp:AsyncPostBackTrigger ControlID="rdFull" EventName="CheckedChanged" />
            </Triggers>
            <ContentTemplate>
                <table width="100%">
                    <tr id="trFullBalTl" class="hide" runat="server">
                        <td style="padding-top: 5px;" id="tdFullBalTerminal">
                            <asp:GridView runat="server" ID="grdFullBalTerminal" AutoGenerateColumns="false" Width="80%" BorderStyle="None" ShowHeader="true">
                                <HeaderStyle CssClass="dlresultheader" Width="15%" Height="30" />
                                <RowStyle CssClass="griditems" VerticalAlign="Bottom" />
                                <EmptyDataTemplate></EmptyDataTemplate>
                                <Columns>
                                    <asp:TemplateField HeaderText="Terminal Id">
                                        <HeaderStyle Width="12%" BorderStyle="None" />
                                        <ItemStyle BorderStyle="none" CssClass="dlresultheader" />
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblFullBalTlId" Text='<%# Eval("terminal") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>

请建议如何编写触发器。

1 个答案:

答案 0 :(得分:1)

我使用了一个隐藏按钮,它是更新面板的触发器。在单选按钮的单击事件上,我使用javascript调用按钮单击事件。