Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Use DataReader as a datasource?
posted

Giving the trial version a run here with the new webdatagrid. Can a data reader be used as a datasource. Tried it so far no luck. It keeps telling me the reader is closed even though I put an if statement around the databinding action. I had a myDataReader.Close in the Finally block of my try catch, but removed it thinking that could be the problem. Still no luck. If I do a response.write on the .FieldCount property of my datareader and comment out the databind code, I get 15 as I expect to. The fact that its getting past the If block tells me that nothing is closed and that there is data. But I noticed in the sample that IDatareader was not one of the bindable datasources...just wondering if it wasn't mentioned, or if in fact, it cannot be used. Thanks.

 If myDataReader.HasRows and myDataReader.IsClosed = False Then

         myGrid.Datasource = myDataReader

        myGrid.DataBind()

End If

Parents
  • 3147
    posted

    Hi,

    Currently we do not support DataReader as DataSource. Please use some alternative data container such as DataSet/DataTable or collection of custom objects.

Reply Children