0
我一直在使用第一頁上的單選按鈕排序的第二頁上的SQL數據庫中顯示錶格的HTML頁面。我的首選語言是C#,我似乎無法正確構建第二頁。目前我正在嘗試將IF語句與LINQ一起使用,但它不起作用。任何人都可以告訴我如何繼續?順便說一句,我是一個完整的業餘愛好者。
HTML代碼:
需要關於HTML表單的一些建議
<body>
<h1>Server Request Form</h1>
<form id="sortradio" action="searchresults.aspx" method="get">
<fieldset>
<legend>Sort Order</legend>
<input type="radio" id="titledesc" name="sortorder" value="Title Desc" />
<label for="titledesc">By Title - Descending</label>
<input type="radio" id="titleasc" name="sortorder" value="Title" />
<label for="titleasc">By Title - Ascending</label>
<input type="radio" id="iddesc" name="sortorder" value="Id Desc" />
<label for="iddesc">By ID - Descending</label>
<input type="radio" id="idasc" name="sortorder" value="Id" />
<label for="idasc">By ID - Ascending</label>
<input type="submit" value="Get Info" />
</fieldset>
</form>
</body>
.aspx的代碼:
<h1>You are sorting by <% Response.Write(Request.QueryString("sortorder"))%>.</h1>
<%
Dim SortingOrder = Request.QueryString("sortorder")
%>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Summary" HeaderText="Summary" SortExpression="Summary" />
<asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" />
<asp:BoundField DataField="GenreId" HeaderText="GenreId" SortExpression="GenreId" />
<asp:CheckBoxField DataField="Authorized" HeaderText="Authorized" SortExpression="Authorized" />
<asp:BoundField DataField="CreateDateTime" HeaderText="CreateDateTime" SortExpression="CreateDateTime" />
<asp:BoundField DataField="UpdateDateTime" HeaderText="UpdateDateTime" SortExpression="UpdateDateTime" />
</Columns>
</asp:GridView>
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:Database1.MDFConnectionString1 %>" providername="<%$ ConnectionStrings:Database1.MDFConnectionString1.ProviderName %>" selectcommand="SELECT [Id], [Title], [Summary], [Body], [GenreId], [Authorized], [CreateDateTime], [UpdateDateTime] FROM [Review] ORDER BY @sortorder">
<Selectparameters>
<asp:querystringparameter name="sortorder" querystringfield="sortorder" />
</Selectparameters>
</asp:SqlDataSource>
</form>`
如果您提供了您目前正在使用的代碼,這將有助於我們瞭解爲什麼它可能無法正常工作。 –
您使用的是什麼技術?如果你是一個Csharper,Asp.net Webform或MVC? – Sean
再次..請告訴我們與問題有關的代碼。你給我們加了標記......你提到的這些「if」陳述在哪裏? –