I can sort columns fine ,but i get an error when i try to do built in paging. I tried everything. My other Datagrid events work fine
Code:
<asp:DataGrid id="ProductDataGrid" OnPageIndexChanged="PageCh
angeClicke
d" OnItemCommand="DetailsClic
ked" OnSortCommand="SortEventHa
ndler" style="Z-INDEX: 101; LEFT: 69px; POSITION: absolute; TOP: 80px" runat="server" Width="273px" Height="558px" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False
" Font-Names="Arial Unicode MS" PageSize="15">
<AlternatingItemStyle BackColor="#CCFF66"></Alte
rnatingIte
mStyle>
<Columns>
<asp:ButtonColumn Text="Details" ButtonType="PushButton" HeaderText="FAQ Details"></asp:ButtonColum
n>
<asp:BoundColumn DataField="product_id" SortExpression="Manufactur
er DESC" HeaderText="Product ID">
<HeaderStyle Font-Size="Large" Font-Underline="True" Font-Names="Book Antiqua" HorizontalAlign="Center" VerticalAlign="Middle"></H
eaderStyle
>
</asp:BoundColumn>
<asp:BoundColumn DataField="Comments" HeaderText="Comments of power">
<HeaderStyle Font-Size="Large" Font-Underline="True" Font-Names="Book Antiqua" HorizontalAlign="Center" VerticalAlign="Middle"></H
eaderStyle
>
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
protected void PageChangeClicked(object sender, DataGridPageChangedEventAr
gs e)
{
ProductDataGrid.CurrentPag
eIndex = e.NewPageIndex;
SqlConnection conn = null;
conn = new SqlConnection("worksfine")
;
String sqlSelect = "SELECT * FROM surplus_inventory";
SqlDataAdapter dAdapt = new SqlDataAdapter(sqlSelect,c
onn);
DataSet myDS = new DataSet();
dAdapt.Fill(myDS,"surplus_
inventory"
);
ProductDataGrid.DataSource
= myDS;
ProductDataGrid.DataBind()
;
}
Error:(happens when I click on next link)
Server Error in '/SurplusInventory' Application.
--------------------------
----------
----------
----------
----------
----------
----
Specified argument was out of the range of valid values.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeE
xception: Specified argument was out of the range of valid values.
Parameter name: index
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentOutOfRangeExcepti
on: Specified argument was out of the range of valid values.
Parameter name: index]
System.Web.UI.ControlColle
ction.get_
Item(Int32
index) +2057582
System.Web.UI.WebControls.
TableCellC
ollection.
get_Item(I
nt32 index) +24
SurplusInventory.DisplaySe
lectList.D
etailsClic
ked(Object
sender, DataGridCommandEventArgs e) +60
System.Web.UI.WebControls.
DataGrid.O
nItemComma
nd(DataGri
dCommandEv
entArgs e) +105
System.Web.UI.WebControls.
DataGrid.O
nBubbleEve
nt(Object source, EventArgs e) +77
System.Web.UI.Control.Rais
eBubbleEve
nt(Object source, EventArgs args) +35
System.Web.UI.WebControls.
DataGridIt
em.OnBubbl
eEvent(Obj
ect source, EventArgs e) +117
System.Web.UI.Control.Rais
eBubbleEve
nt(Object source, EventArgs args) +35
System.Web.UI.WebControls.
LinkButton
.OnCommand
(CommandEv
entArgs e) +115
System.Web.UI.WebControls.
LinkButton
.RaisePost
BackEvent(
String eventArgument) +163
System.Web.UI.WebControls.
LinkButton
.System.We
b.UI.IPost
BackEventH
andler.Rai
sePostBack
Event(Stri
ng eventArgument) +7
System.Web.UI.Page.RaisePo
stBackEven
t(IPostBac
kEventHand
ler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePo
stBackEven
t(NameValu
eCollectio
n postData) +174
System.Web.UI.Page.Process
RequestMai
n(Boolean includeStagesBeforeAsyncPo
int, Boolean includeStagesAfterAsyncPoi
nt) +5102