iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I want to accomplish a simple task with the WebCombo control. Create the object, configure it, assign the data source and have it render. Now when I click on it to pull it down, I do NOT want it to post back. I want it to be pre-filled already.
I know I can accomblish this as an UNBOUND object, however, the problem is that I can't assign a value and text. An unbound object uses the text as both the value and text and this doesn't work for us. In the example below, you see how we create the object dynamically which works, but then I have no way to know what the id of an entry is. The cbo object below is of type ISNet.WebUI.WebCombo.WebCombo
// configure the combo box for immediate population cbo.EnableViewState = false; cbo.AllowAutoPostback = false; cbo.LayoutSettings.ComboMode = ISNet.WebUI.WebCombo.Mode.SingleColumn; cbo.ViewStateStorage = ISNet.WebUI.StateCacheStorage.None; // create a single column set to unbound mode ISNet.WebUI.WebCombo.WebComboColumn wcc = new ISNet.WebUI.WebCombo.WebComboColumn(); wcc.Bound = false; cbo.Columns.Add(wcc); // populate the combo list string strDefaultValue = CPRISMStrLib.GetStr(drOptions["defaultValue"]); string strDefaultText = string.Empty; foreach (DataRow dr in ds.Tables[0].Rows) { ISNet.WebUI.WebCombo.WebComboRow wcr = new ISNet.WebUI.WebCombo.WebComboRow(); ISNet.WebUI.WebCombo.WebComboCell cell = new ISNet.WebUI.WebCombo.WebComboCell(); cell.Text = CPRISMStrLib.GetStr(dr["listName"]); cell.Value = CPRISMStrLib.GetStr(dr["listID"]); wcr.Cells.Add(cell); cbo.Rows.Add(wcr); if (CPRISMStrLib.GetStr(cell.Value) == strDefaultValue) { strDefaultText = cell.Text; cbo.SelectedText = strDefaultText; cbo.Value = strDefaultText; } }
I can easily accomplish with a standard DropDownList and the value/text pairs set up via the ListItem type. I'm not sure why it seems so complicated to accomplish this via WebCombo.
Even through I set the .Value property above (in blue), the rendered html dataValue attribute is set to the value assigned to Text and not Value.
To show the default item in the combo box, setting cbo.Value to strDefaultValue does not work which is why, in that section, I set to strDefaultText (in red).
Well, I had to get a little creative, but I've found a work-around for now. I basically use multiple columns with my "id" column hidden. I did notice that the first column, in Unbound mode, must be the visible one. So my second column is rendered hidden and contains my value/id as its text. Of course it can only be retrieved via the cells collection in case you're wondering.
Hi Yousif,
I am sorry about my previous statement that unbound WebCombo cannot have value, afer checking again we have PopulateUnbound method that can bind WebCombo like unbound but still use the datatable as the datasource. Here I attached my simple sample, using this sample the WebCombo will have Text and Value field.
Best Regards,
Gordon Tumewu
Note: This solution has not approved yet by the customer, this will be the solution once the customer has aggree first.
Well, technically I changed the DataSourceID that was already there in your sample. I just changed it from an Access source to a SQL source. ;) But you nailed it. Removing the DataSourceID did the trick. However, I did not want to use multiple columns but just a normal pulldown list and I accomplished it with the following configuration:
ASPX Markup
<ISWebCombo:WebCombo ID="WebCombo1" runat="server" Height="20px" Width="200px" > </ISWebCombo:WebCombo>
Codebehind:
combo.DataMember = "DefaultView"; combo.DataTextField = "reportSetName"; combo.DataValueField = "reportSetID"; combo.LayoutSettings.StatusBoxVisible = false; combo.Columns.Add("reportSetName"); combo.Columns.Add("reportSetID"); DataView dv = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments("reportSetID DESC")); combo.PopulateUnboundData(dv,false);
Thanks Gordon.
Hi,
Yes, it is true, the WebCOmbo behaviour is different than the dropdownlist, if you used the bound WebCombo then the everytime you click the dropdown the flypostback will occured. If you want the WebCombo to load on the first time like dropdownlist then you need to use the Unbound webcombo but then again the value will not be supported.
Wow, that's horrible. You guys need to add this feature for bound combo boxes. How can you force the user to post back when they may have an application that doesn't need it for small data sets? Also, you need to add the ability to have value/text pairing in unbound combo boxes. I mean this is a simple thing that's easily achieved with an asp.net combo and an html combo.
Yeap, that's why we provided unbound mode, that's why customer that have small data set can load all the data at the load time. And yes it is true that this simple thing easily achieved with asp.net combo but as I said before our WebCombo behaviour is different than asp.net dropdownlist because we have the filtering feature that's why our development team design it to be flypostback.
I'm running into one more issue with the solution above. Even though I can store the value in a hidden cell, when I finally post the page back, I cannot retrieve this value. When I check the Page.Request.Params collection, only the combo box text is available and the value is not part of the fields posted back. Any ideas on how to retrieve this value? Thanks.
Hi Grodon,
Thank you so much. I had a feeling you guys had to have something like this. I'm sorry I couldn't find it in the references as I looked and looked. This is a huge deal so I'm glad you were able to dig it up. Thanks again.
Gordon,
Although this works with an unbound data set. It still posts back and that's what I don't want. I need the combo box to populate with all the data items and NOT post back per my original description please. Please unmark your response as an answer since it has not provided a solution to this issue. Thank you.
I am sorry I dont have priviledge to cancel the mark as answer, but I have added note that the post is not the right answer, and if we have found the correct answer I will put the answer in the post.
For the solution that I gave you before, I have test it and didn't found any postback to the server accept for the first time the WebCombo load. Here I attached video on how I debug using the sample that I provided to you before.
I appreciate the video and all, but it doesn't resolve the "problem." I need the combo to be filled upon rendering and to not post back at all. Just like it does in unbound mode but I have to be able to have a value/text pair in that mode.
I am really sorry but in your first post you said that:
and if I am not mistaken the WebCombo sample that I sent before have the same behaviour, it will load the data at the first time and when you click to pull it down the postback did not occured. You can see it in my video before.
Please correct me if I am wrong, do you experience the postback everytime you click the dropdown in my sample? Or do you experience the issue in your application only?
Best Regards.
Yes, I experience the post back with your sample. I had to modify it to use a SQL data source, but that's it. I've included my video and you can see it post back when I pull it down the first time. I put a block of code in with a check for Page.IsPostBack to make it clear.
Thank you very much for the video, it helps me to investigate the issue. After checking the video I suspect that the cause if the issue is because you set the DataSourceID of WebCombo. Actually without setting the DataSourceID the WebCombo will still have the data because you have used the PopulateUnboundData. By removing the DataSourceID property from WebCombo I believe it should fix the issue.
Please let me know if the solution works or not. Thanks.
Great to hear that you have solved the problem.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname