Setting items in a combo box based on another column - at load

Posted by: helenmortlock on 8 September 2017, 11:18 am EST

    • Post Options:
    • Link

    Posted 8 September 2017, 11:18 am EST

    Hello!

    I am a real novice when it comes to FarPoint so apologies if the answer to this post is really obvious! 

    I have been using this excellent post to produce a combo box that is affected by a change to another combo box and this is working!  http://www.clubfarpoint.com/Forums/forums/thread/3838.aspx

    BUT this is only happening once the first combo box is updated, not when the page is originally loaded, which is as I would expect from the code. I'm not expecting this code to work on the page load, but I'm wondering what I have to add to get this working as well!!

    Hopefully some details will make this clearer....

    Combobox 1 is a list of countries

    Combobox2 is a list of 'cresta' codes, and we only want the codes relevant to the country selected in that row to be shown as options.

    The fpspread1 is populated from a SQL Server table and the country and code for each record/row are stored in there.  The 2 combo box options are also populated from other SQL tables. When the page is loaded the country and cresta are showing the stored values from the data table, but if I try and update the Cresta column, it doesn't limit the values to the country stored.  If I reset the country, it then limits the cresta codes to the new country selected.  I've set the intial load of the cresta combo box to pull back ALL records, but I need to change this!

    What I need to know is how I can set the initial cresta combo box items to be based on the country stored value, but for each row (which can have different values for Country)?

    Any help appreciated!

    Thanks,

    Helen

  • Posted 8 September 2017, 11:18 am EST

    You would use the same Select Case logic you have in your UpdateCommand Event, in the Page_Load Event.

  • Posted 8 September 2017, 11:18 am EST

    Hi Paul,

    Thanks for your reply.

    I'm not acutally using the select case logic, but am passing the new country code into an SQL stored procedure as a parameter using the e.EditValues(0).ToString() where e is the FarPoint.Web.Spread.SpreadCommandEventArgs from the FpSpread1_UpdateCommand.  What is the equivalent value for this in the Page_Load event?

    My initial page load uses a stored procedure to return the saved records (returned to a dataset which is then assigned as the FpSpread1's datasourse), so I'm not sure what I use to pass the country code into the lookup stored procedure in the page_load event.  Do I need to loop through each row and call the stored procedure each time or is there a way of doing this as each row is loaded - I've seen some code using 'PaintCell' and wondered if this would work??

    The country code is stored in FpSpread1.column(0), the cresta code this should be passed into is the FpSpread1.column(3).

    I have tried using the following code:

    Dim crestaSQL As String = "exec usp_aggs_get_cresta_zone " + FpSpread1.ActiveSheetView.Columns(0).ToString

    But didn't think that would work and it doesn't!!  I just need to know what I need to use to pass into this stored procedure in the page_load event, so any advice would be gratefully received!

    Thanks again for your help so far!

    Helen

  • Posted 8 September 2017, 11:18 am EST

    I have worked this out now!

    I've put in a loop to go through each row in the FpSpread1.ActiveSheetView and passed in the column(0) cell value for each row as it hits.

    This works great.

    Thanks again for your help.

    Helen

  • Posted 29 September 2017, 11:27 am EST

    This link from above doesn’t seem to be working, but it may contain information that would be helpful for me. Might you please be able to post a new link?

    http://www.clubfarpoint.com/Forums/forums/thread/3838.aspx

    Karen

  • Posted 3 October 2017, 10:21 pm EST

    Hello,

    Please go through this forum link for the same:-

    https://www.grapecity.com/en/forums/spread-webforms/combo-box-cell-type---auto

    Hope it helps.

    Thanks,

    Reeva

  • Posted 4 October 2017, 10:16 am EST

    Thanks, Reeva!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels