WebCombo Rendering Items Without Postback

15 replies. Last post: November 15, 2009 10:53 PM by Gordon Tumewu
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
A YousifMember

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).

All times are GMT -5. The time now is 2:46 AM.
Previous Next