Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在单击gridview中的链接按钮后在gridview中正确获取单元格值,并启用正确的异步回发以显示模式_C#_Asp.net_Gridview_Postback_Ajaxcontroltoolkit - Fatal编程技术网

C# 如何在单击gridview中的链接按钮后在gridview中正确获取单元格值,并启用正确的异步回发以显示模式

C# 如何在单击gridview中的链接按钮后在gridview中正确获取单元格值,并启用正确的异步回发以显示模式,c#,asp.net,gridview,postback,ajaxcontroltoolkit,C#,Asp.net,Gridview,Postback,Ajaxcontroltoolkit,我正在预订系统,目前遇到以下情况 基本上,我有一个GridView,其中加载了预订ID,还有两个LinkButton,它打开一个模式弹出窗口,让客户能够查看详细信息 我想要实现的是,当我单击任何链接按钮时,它将显示网格视图行的第一个单元格的ID 我试过这些方法,但仍然不起作用。除了使用SELECT命令之外,还有什么方法可以做到这一点,并且确实涉及到异步回发,或者如果异步回发无法实现,建议进行任何修复 这是我的GridView代码: <asp:UpdatePanel runat="serve

我正在预订系统,目前遇到以下情况

基本上,我有一个
GridView
,其中加载了预订ID,还有两个
LinkButton
,它打开一个模式弹出窗口,让客户能够查看详细信息

我想要实现的是,当我单击任何
链接按钮时,它将显示
网格视图行的第一个单元格的ID

我试过这些方法,但仍然不起作用。除了使用SELECT命令之外,还有什么方法可以做到这一点,并且确实涉及到异步回发,或者如果异步回发无法实现,建议进行任何修复

这是我的
GridView
代码:

<asp:UpdatePanel runat="server" UpdateMode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="gvReservationSummaries"/>
            </Triggers>
            <ContentTemplate>
                <h2>Reservations</h2>
                <br />
                <asp:GridView ID="gvReservationSummaries" runat="server" 
                    AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
                    AllowPaging="True" ShowHeader="False" CellPadding="5" CellSpacing="5" 
                    onrowcommand="Gridview1_RowCommand">

                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server"><%# Eval("Master_Reservation_ID")%></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:LinkButton runat="server" CommandName="ViewReservationDetails" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>View Reservation Details</asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:LinkButton runat="server" CommandName="ViewReceiptDetails" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'>View Receipt Details</asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>

                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DB_9E4ABD_GratchiOBRSConnectionString2 %>" 

                    SelectCommand="SELECT [Master_Reservation_ID] FROM [Master_Reservation] WHERE User_Unique_ID = @uuid">
                    <SelectParameters>
                        <asp:SessionParameter Name="uuid" SessionField="uid" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                <asp:Button ID="btnShowModal" runat="server" Text="Show Modal 1 (Debug Purposes Only)" onclick="btnShowModal_Click" />
                <!--Here, put the details of the reservaton, plus options to edit reservation.-->      
            </ContentTemplate>
        </asp:UpdatePanel> 
    </div>
</div>
<asp:Panel ID="reservationSummaryModal" runat="server" Width="500px" Height="500px" style="display: none; background-color:Black; color:#CCC;">
    <asp:Button ID="btnExitRs" runat="server" Text="Hide Modal (Debug Purposes Only)" onclick="btnExitAct_Click" />
    <asp:Label ID="lblReservationSummary" runat="server" Text="Label"></asp:Label>
</asp:Panel>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="HiddenField1" PopupControlID="reservationSummaryModal" BackgroundCssClass="modalBg" CancelControlID="btnExitRs">
</asp:ModalPopupExtender>
<asp:HiddenField ID="HiddenField1" runat="server" />

你说它不起作用。您在
lblReservationSummary.Text中实际看到了什么?根据代码,它不显示任何内容。
protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "ViewReservationDetails")
        {
            //GridViewRow gvr = gvReservationSummaries.Rows[Convert.ToInt32(e.CommandArgument)];
            gvReservationSummaries.SelectedIndex = Convert.ToInt32(e.CommandArgument);

            GridViewRow gvr = gvReservationSummaries.Rows[gvReservationSummaries.SelectedIndex];

            lblReservationSummary.Text = "The id is: " + gvr.Cells[0].Text.ToString();
            ModalPopupExtender1.Show();
        }

        else if (e.CommandName == "ViewReceiptDetails")
        {
            gvReservationSummaries.SelectedIndex = Convert.ToInt32(e.CommandArgument);

            GridViewRow gvr = gvReservationSummaries.Rows[gvReservationSummaries.SelectedIndex];

            lblReservationSummary.Text = "The id is: " + gvr.Cells[0].Text.ToString();
            ModalPopupExtender1.Show();
        }

        else
        {

        }
    }