0
好的,好吧,我在他的第9部分等博客中跟隨了Scott Gu的例子,儘管我盡了最大努力實現'自動排序,分頁和編輯,但是我無法獲得某某工作。使用LINQ進行分頁,排序和編輯數據源
自動排序,分頁和編輯可能與以下設置?
<asp:TextBox ID="tbxHowMany" runat="server"></asp:TextBox>
<asp:RadioButtonList ID="radMaterial" runat="server">
<asp:ListItem>Paper</asp:ListItem>
<asp:ListItem>Glass</asp:ListItem>
</asp:RadioButtonList>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="LQTOPDS" Font-Size="XX-Small" ForeColor="#333333"
GridLines="None" DataKeyNames="PriKey"
AllowPaging="True" AllowSorting="True">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Productpriority" HeaderText="Productpriority"
SortExpression="Productpriority" />
<asp:BoundField DataField="MemberId" HeaderText="MemberId"
SortExpression="MemberId" />
<asp:BoundField DataField="UnitWeight" HeaderText="UnitWeight"
SortExpression="UnitWeight" />
<asp:BoundField DataField="WeightUnitCode" HeaderText="WeightUnitCode"
SortExpression="WeightUnitCode" />
<asp:BoundField DataField="RecycledContent" HeaderText="RecycledContent"
SortExpression="RecycledContent" />
<asp:BoundField DataField="IsBiodegradable" HeaderText="IsBiodegradable"
SortExpression="IsBiodegradable" />
<asp:BoundField DataField="Recyclability" HeaderText="Recyclability"
SortExpression="Recyclability" />
<asp:BoundField DataField="RevisionSourceCode" HeaderText="RevisionSourceCode"
SortExpression="RevisionSourceCode" />
<asp:BoundField DataField="PriKey" HeaderText="PriKey"
SortExpression="PriKey" ReadOnly="True" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:LinqDataSource ID="LQTOPDS" runat="server"
ContextTypeName="LQTOPDSDataContext" EnableInsert="True" EnableUpdate="True"
TableName="tblOnlineReportingCOMPLETEWEIGHTSFINALs"
Where="MaterialText == @MaterialText && Productpriority <= @Productpriority">
<WhereParameters>
<asp:ControlParameter ControlID="radMaterial" Name="MaterialText"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="tbxHowMany" Name="Productpriority"
PropertyName="Text" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
目前暫列我唯一的代碼如下:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSourceID = null;
}
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.DataSourceID = "LQTOPDS";
GridView1.DataBind();
}
}
這是推動我堅果...我讀這個排序/分頁/編輯功能應是自動的,但顯然我做錯了什麼。
如果有人能向我解釋爲什麼這個功能沒有生成,我將不勝感激。