Welcome Guest Search | Active Topics | Sign In | Register

Grid and SQlDataSource Not Loading Options
ROI.Solutions
Posted: Wednesday, May 7, 2008 11:51:14 AM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
OK,

Im using a grid and wanting to populate it from a SQLDataSource. I set all the sections as needed but nothing populates.

I had a similar problem when populating the Menu from a SQDataSource and had to add

menu1.Datasource = SqlDatSOurce1.Select(DataSourceSelectArguments.Empty)
menu1.DataBind()

to the OnPage_Load event and i did that with this one and still no luck. Is there an issue with the SQLDataSource object and the grid or do i have to specify someting im missing
eo_support
Posted: Wednesday, May 7, 2008 12:05:29 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi Loren,

I don't think there is an issue with SqlDataSource or the Grid. Ideally the Grid should support SqlDataSource directly through DataSourceID, but SqlDataSource1.Select should do exactly the same because even if the Grid were to support DataSourceID directly, calling Select and setting the DataSource would be what it does internally.

In order to troubleshoot the problem, first check what Select returns. It supposes to return a DataView or an IDataReader object. If it returns a DataView object, check whether it has any rows by checking its Count property. If it returns an IDataReader (for example, SqlDataReader) object, check whether it has any rows by calling its Read method and then check the return value of Read method. If either case indicates that there are no rows, then the Grid certainly won't populate because it has not been fed any data.

If the data source does have data, you want to check whether the Grid does not render any rows, or renders empty rows with no data. The first case should not happen, but if it does happen, we will be happy to take a look; For the second case it has to do with your DataField setting on each column. When DataField is not correctly set, you will get empty rows but no data.

Thanks
ROI.Solutions
Posted: Wednesday, May 7, 2008 12:20:26 PM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
It Returns a Dataview i created a real quick Temp DataView and row count comes back as expect to be 2. how do i set the grid to use the DataView prgramatically i tried DataSource and SourceID but nothing. Sample Code below

Code: Visual Basic.NET
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure

        Dim oDV As Data.DataView

        oDV = SqlDataSource1.Select(DataSourceSelectArguments.Empty)

        Grid1.DataSourceID = "oDV"
    End Sub
End Class
ROI.Solutions
Posted: Wednesday, May 7, 2008 12:23:28 PM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
OK i go it to show the Numbers of rows but the Cells and Header are still defaulted. I tried this with an ASP gridView and works so i just need to know how to set the Header and Cells essesntailly

Code: Visual Basic.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure

        Dim oDV As Data.DataView

        oDV = SqlDataSource1.Select(DataSourceSelectArguments.Empty)

        Grid1.DataSource = oDV
        Grid1.DataBind()

        GridView1.DataSource = oDV
        GridView1.DataBind()
    End Sub
eo_support
Posted: Wednesday, May 7, 2008 12:29:16 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

Check the Grid columns' property. There aren't many and you will find your answer very quickly there. :)

Thanks
ROI.Solutions
Posted: Wednesday, May 7, 2008 12:46:42 PM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
Ah found it thnx. Now For the Grid they have a buil in Button and Edit Columns but i can find out how to chweck where the link goes to Essentially Im going to have them load a new ASP page. But how can this be done?
eo_support
Posted: Wednesday, May 7, 2008 12:57:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

You can take a look of ClientSideOnItemCommand. You can write your own JavaScript handler for that event and when a button is clicked, your handler will be called. You can then do whatever you like to do there.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.