quickstart db sample?

  • Thread starter Thread starter LL
  • Start date Start date
L

LL

Hi,

I'm trying datagrid9.aspx sample:Updating a Row of Data w/ Validation.

But after I set the paging property, when I click the page number, it won't
go to the next page. Any ideas?

Thanks...
 
Hi

Did you set the newpageindex to currentpageindex in
datagrid paging event


Try this:
Private Sub PageGrid(ByVal source As Object, ByVal e As
DataGridPageChangedEventArgs)
MyDataGrid.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub


HTH
Ravikanth[MVP]
 
Thanks Ravikanth.

But the second page is empty?

I'm running datagrid9.aspx.

private void MyDataGrid_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)

{

// Set CurrentPageIndex to the page the user clicked.

MyDataGrid.CurrentPageIndex = e.NewPageIndex;

MyDataGrid.DataBind();

}
 
Another question:

How to enable "sort" function in the datagrid9.aspx sample?
Thanks for the help!
 
Actually I got this error when I enable "sorting" property and click Update:

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:

Line 97: myCommand.Parameters.Add(new SqlParameter("@Contract",
SqlDbType.NVarChar,1));
Line 98:
Line 99: myCommand.Parameters["@Id"].Value =
MyDataGrid.DataKeys[(int)E.Item.ItemIndex];
Line 100:
Line 101: String[] cols =
{"LName","FName","Phone","Address","City","Zip"};

Source File: c:\project\autosales\datagrid9.aspx.cs Line: 99



myCommand.Parameters["@Id"].Value =
MyDataGrid.DataKeys[(int)E.Item.ItemIndex];

How to fix it?
 
LL said:
Actually I got this error when I enable "sorting" property and click Update:

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:

Line 97: myCommand.Parameters.Add(new SqlParameter("@Contract",
SqlDbType.NVarChar,1));
Line 98:
Line 99: myCommand.Parameters["@Id"].Value =
MyDataGrid.DataKeys[(int)E.Item.ItemIndex];
Line 100:
Line 101: String[] cols =
{"LName","FName","Phone","Address","City","Zip"};

Source File: c:\project\autosales\datagrid9.aspx.cs Line: 99

myCommand.Parameters["@Id"].Value =
MyDataGrid.DataKeys[(int)E.Item.ItemIndex];

How to fix it?

Well the first thing to do is find out what E.Item.ItemIndex is, I'd
think...
 
Back
Top