I am using Datagrid ItemCommand with my datagrid, but doing so messes with 
my paging and results in the below error when I click any of the paging 
links.
 Code:
 
private void DataGrid_ItemCommand(object sender, 
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
FillEditPanel((int)dgSearchRes.DataKeys[e.Item.ItemIndex]);
}

private void DataGrid_ItemDataBound(object sender, 
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Header)
{
e.Item.Cells[0].Text = "First Name";
e.Item.Cells[1].Text = "Last Name";
e.Item.Cells[2].Text = "Email";
e.Item.Cells[3].Text = "Phone";

if(IsReadOnly())
e.Item.Cells[4].Text = "View";
else
e.Item.Cells[4].Text = "Edit";
}
}

private void DataGrid_Paging(object sender, 
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
SetupDataGrid();
dgSearchRes.CurrentPageIndex = e.NewPageIndex;
BindData();
}

Error:
 *Index was out of range. Must be non-negative and less than the size of the 
collection. 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.ArgumentOutOfRangeException: Index was out of 
range. Must be non-negative and less than the size of the collection. 
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:* 

  [ArgumentOutOfRangeException: Index was out of range.  Must be
non-negative and less than the size of the collection.
Parameter name: index]
   System.Collections.ArrayList.get_Item(Int32 index) +91
   System.Web.UI.WebControls.DataKeyCollection.get_Item(Int32 index) +10
   _911PigeonAlert.Search.DataGrid_ItemCommand(Object sender,
DataGridCommandEventArgs e) in
c:\inetpub\wwwroot\beta.911pigeonalert.org\rescuers\search.aspx.cs:135
   System.Web.UI.WebControls.DataGrid.OnItemCommand(DataGridCommandEventArgs
e) +110
   System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source,
EventArgs e) +68
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
   System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source,
EventArgs e) +100
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +120
   
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +115
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
   System.Web.UI.Page.ProcessRequestMain() +1292


------------------------------
*Version Information:* Microsoft .NET Framework Version:1.1.4322.2032; 
ASP.NET <http://ASP.NET> Version:1.1.4322.2032 

-- 
Thank you,
Ryan Olshan
<asp:WebProgrammer />
TeraNet Systems
http://www.teranetsystems.com


[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to