本文介绍了为什么在GridView中选择后数据未在Form View中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在GridView中选择后数据没有显示在Form View中?

我想在选择Gridview后在表单视图中显示详细信息.

网格视图和数据源如下所示.

Why data is not showing in Form View after selecting in GridView?

I want to display details in form view after selection of Gridview.

The Grid View and Data Source is given below.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 

                        AutoGenerateColumns="False" CellPadding="3" DataKeyNames="qid" 

                        DataSourceID="SqlDataSource5" GridLines="Vertical" 

                        onselectedindexchanged="GridView1_SelectedIndexChanged" 

                        style="margin-left: 23px" Width="582px" BackColor="White" 

                        BorderColor="#999999" BorderStyle="None" BorderWidth="1px" 

                        AllowSorting="True">
                        <AlternatingRowStyle BackColor="#DCDCDC" />
                        <Columns>
                            <asp:BoundField DataField="qname" HeaderText="qname" SortExpression="qname" />
                            <asp:CommandField ShowSelectButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#F1F1F1" />
                        <SortedAscendingHeaderStyle BackColor="#0000A9" />
                        <SortedDescendingCellStyle BackColor="#CAC9C9" />
                        <SortedDescendingHeaderStyle BackColor="#000065" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource5" runat="server" 

                        ConnectionString="<%$ ConnectionStrings:tuitionConnectionString %>" 

                        SelectCommand="SELECT * FROM [question] WHERE (([sid] = @sid) AND ([aid] = @aid) AND ([cid] = @cid))">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="DropDownList2" Name="sid" 

                                PropertyName="SelectedValue" Type="String" />
                            <asp:ControlParameter ControlID="DropDownList3" Name="aid" 

                                PropertyName="SelectedValue" Type="String" />
                            <asp:ControlParameter ControlID="DropDownList4" Name="cid" 

                                PropertyName="SelectedValue" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>


FormView如下所示.


The FormView is given below.

<asp:SqlDataSource ID="SqlDataSource6" runat="server" 

                        ConnectionString="<%$ ConnectionStrings:tuitionConnectionString %>" 

                        

                        SelectCommand="SELECT * FROM [answer] WHERE ([qid] = @qid)" 

                        onselecting="SqlDataSource6_Selecting">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="GridView1" Name="qid" 

                                PropertyName="SelectedValue" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:FormView ID="FormView1" runat="server" 

                        BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" 

                        CellPadding="4" DataSourceID="SqlDataSource6" 

                        GridLines="Both" onpageindexchanging="FormView1_PageIndexChanging" 

                        DataKeyNames="qid">
                        <EditItemTemplate>
                            ansid:
                            <asp:Label ID="ansidLabel1" runat="server" Text='<%# Eval("ansid") %>' />
                            <br />
                            ansdesc:
                            <asp:TextBox ID="ansdescTextBox" runat="server" Text='<%# Bind("ansdesc") %>' />
                            <br />
                            sid:
                            <asp:TextBox ID="sidTextBox" runat="server" Text='<%# Bind("sid") %>' />
                            <br />
                            aid:
                            <asp:TextBox ID="aidTextBox" runat="server" Text='<%# Bind("aid") %>' />
                            <br />
                            cid:
                            <asp:TextBox ID="cidTextBox" runat="server" Text='<%# Bind("cid") %>' />
                            <br />
                            qid:
                            <asp:TextBox ID="qidTextBox" runat="server" Text='<%# Bind("qid") %>' />
                            <br />
                            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 

                                CommandName="Update" Text="Update" />
                             <asp:LinkButton ID="UpdateCancelButton" runat="server" 

                                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </EditItemTemplate>
                        <EditRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                        <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
                        <InsertItemTemplate>
                            ansid:
                            <asp:TextBox ID="ansidTextBox" runat="server" Text='<%# Bind("ansid") %>' />
                            <br />
                            ansdesc:
                            <asp:TextBox ID="ansdescTextBox" runat="server" Text='<%# Bind("ansdesc") %>' />
                            <br />
                            sid:
                            <asp:TextBox ID="sidTextBox" runat="server" Text='<%# Bind("sid") %>' />
                            <br />
                            aid:
                            <asp:TextBox ID="aidTextBox" runat="server" Text='<%# Bind("aid") %>' />
                            <br />
                            cid:
                            <asp:TextBox ID="cidTextBox" runat="server" Text='<%# Bind("cid") %>' />
                            <br />
                            qid:
                            <asp:TextBox ID="qidTextBox" runat="server" Text='<%# Bind("qid") %>' />
                            <br />
                            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 

                                CommandName="Insert" Text="Insert" />
                             <asp:LinkButton ID="InsertCancelButton" runat="server" 

                                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <br />

                            ansdesc:
                            <asp:Label ID="ansdescLabel" runat="server" Text='<%# Bind("ansdesc") %>' />
                            <br />
                            <br />

                        </ItemTemplate>
                        <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                        <RowStyle BackColor="White" ForeColor="#330099" />
                    </asp:FormView>

推荐答案


The FormView is given below.


The FormView is given below.

<asp:SqlDataSource ID="SqlDataSource6" runat="server" 

                        ConnectionString="<%




这篇关于为什么在GridView中选择后数据未在Form View中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 02:21