PDA

View Full Version : Help with: Datagrid Paging


justnew
04-04-2005, 10:07 PM
I want to enable paging in my datagrid. I presently use datareader to display the content of the datagrid. I found some where on the net that using DataReader as datasource, I would not be able to page because it is read only. Can someone help me to convert this code to dataset. Here is my code both Store_Procedure and code behind. Thanks in advance

Here is Stored Procedure:
Create Proc SP_Computers

As
SELECT Product.CategoryID, Product.Product, Product.SellerID, Product.Price, Product.Descriptions,Product_Image.ImageID,
Product_Image.ProductID, Product_Image.LGimgname, Product_Image.LGimgdata,Product_Image.LGimgcontenttype,
Product_Image.SMimgname, Product_Image.SMimgdata, Product_Image.SMimgcontenttype, Product_Image.UploadDate
FROM Product INNER JOIN
Product_Image ON Product.ProductID = Product_Image.ProductID
where CategoryID = 2
Order by Price asc

Here is my Sub Databind in the code behind:

Private Sub BindGrid()

Dim myconnection As New SqlConnection("Server=mysqlserver; Initial Catalog=dbproducts; UID=myUIDrs; Password=mypwd; Network Library=dbmssocn;")
Dim myCommand As SqlCommand = New SqlCommand("SP_Computers", myconnection)

' Mark the Command as a SPROC

myCommand.CommandType = CommandType.StoredProcedure

Try

myconnection.Open()

dgImages.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
dgImages.DataBind()


Catch SQLexc As SqlException

Response.Write("Error occured while Generating Data. Error is " & SQLexc.ToString())

End Try

end sub