richard.anthony@cfp-software.c Posted February 19, 2008 Report Share Posted February 19, 2008 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 Quote Link to comment Share on other sites More sharing options...
AngelR Posted February 20, 2008 Report Share Posted February 20, 2008 Richard, 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 Quote Link to comment Share on other sites More sharing options...
richard.anthony@cfp-software.c Posted February 25, 2008 Author Report Share Posted February 25, 2008 in the Page Load event, I have; Select Case UCase(Request.QueryString("Display")) Case "WORKSHEETS" Me.grdfxOrganiserSubGrid.DataBind() 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" Height="200px"> <titlebar subtitle="Please select above" title="Nothing selected" visible="True"> <Image Icon="None"></Image> <Style HorizontalAlign="Left"></Style> </titlebar> <columns> <GridFX:FieldColumn Field="Please Select MODE Above"></GridFX:FieldColumn> </columns> <datafields> <GridFX:NumberField ReadOnly="True" DataPath="Please Select MODE Above"></GridFX:NumberField> </datafields> </GridFX:Grid> 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. Quote Link to comment Share on other sites More sharing options...
AngelR Posted February 25, 2008 Report Share Posted February 25, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.