Jump to content
Software FX Community

Change a GridFX's data source...

Recommended Posts

Hi, Support team;

 I am trying to use Gridfx in a way which uses a single grid and re-binds to different SQL statements depending on user input, and thus will need to show different fields as a result of the change in datasource...

 The way I have gone about it is to create an sql datasource and by default bind the grid to that source, then when appropriate to change the sql datasource's "SelectCommand" property...  But then I get stuck!

 I have tried re-binding the control but get runtime errors indicating that the original field names are no-longer available.

I have tried programatically clearing all the datafields (grid.datafield.clear) then adding datafields via creating a new instance of a datafield class and datafield.add(reference to instance) which appears fine via the runtime object explorer, but at runtime still fails with a similar message ("Empty Property 'DataPathDescriptor' - GridField originaldatafieldname' is bound to the 'originalsqlfieldname' DataPath but had no DataPathDescriptor set.").  I could obviously do the whole thing unbound - but surely there is a faster way?

I'm pretty sure that the grid.datafields.clear() isn't doing what I think it should - but can't find an answer (I'm using vb under asp.net, by the way).

I admit that I'm new to asp.net, but have about 20 years industrial development experience so am beginning to beat myself up that I can't figure it out!  Please put me out of my misery - how should I do it?...

 Yours hopefully...

 Richard Anthony

Link to comment
Share on other sites


Grid FX elements are integrated in the Grid at different times. We are finishing a map of events to assist programmers understanding the best place to use Grid FX Events depending on what objects they need to use. For example, DataBound is the preferred event if you want to read data once is in the grid, different to Databinding that is when Grid FX fills Grid data store objects. It is the same when creating Datafields and Columns: they need to be there before the grid tries to populate or use them.

Maybe you can send us your aspx markup and code behind so we can analyze it and troubleshoot you further. I

Link to comment
Share on other sites

 in the Page Load event, I have;

  Select Case UCase(Request.QueryString("Display"))



  Case Else

  Me.grdfxOrganiserSubGrid.Visible = False

  End Select

Then, in the grdfxOrganiserSubGrid_DataBinding event, I have;

Dim lDataAdapter As New SqlDataAdapter

  Dim gridDataset As DataSet

  Dim gridDataView As DataView

  lDataAdapter = New SqlDataAdapter

  lDataAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand("SELECT LCode, LName, LAdd1, LAdd2, LAdd3, LAdd4 FROM Land_Inf", conMainConnection)

  gridDataset = New DataSet

  lDataAdapter.Fill(gridDataset, "Land_Inf")

  gridDataView = New DataView

  gridDataView = gridDataset.Tables("Land_Inf").DefaultView

  grdfxOrganiserSubGrid.DataSource = gridDataView


- Which I thought (From the examples I have found) would do the job (Please note that the conMainConnection is a PUBLIC SqlConnection previously defined and opened).


Does't do anything, though!


The markup is:

  <GridFX:Grid id="grdfxOrganiserSubGrid" runat="server" DataSourceID="SqlOrganiserSubGrid"


  <titlebar subtitle="Please select above" title="Nothing selected" visible="True">

<Image Icon="None"></Image>

<Style HorizontalAlign="Left"></Style>



<GridFX:FieldColumn Field="Please Select MODE Above"></GridFX:FieldColumn>



<GridFX:NumberField ReadOnly="True" DataPath="Please Select MODE Above"></GridFX:NumberField>



 Where the datasource of SQLOrganiserSubGrid is a simple "select NULL as[Please Select MODE Above]" placeholder.


Thanks for your help thus-far - if you think the hotfix is appropriate for my needs I'd be more than happy to give it a whirl!



- Richard Anthony.

Director of New Developments.

Link to comment
Share on other sites

You are getting those errors because your application uses a dynamic Datasource selection; then you have to clear not only Grid fields but columns as well, since they stay in the grid after the first data bound.

I definitely believe you can use the last Hotfix to take advantage of the new event (DatasourceSelecting). You
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...