Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
WebCombo.DataValue returns null on second postback (doesn't persist)

Hello everyone,

First of all, I'm using WebCombo v6.3 (and ASP.NET 2.0)

I have a webcombo aspx markup below:

            <igcmbo:WebCombo ID="wc" runat="server">

            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> 

Then in the codebehind I enable xml HTTP, editable, type ahead suggest, subscribe and implement InitializeDataSource event handler.

using System;
using System.Web;
using Infragistics.WebUI.WebCombo;

public partial class Default2 : System.Web.UI.Page
    protected override void OnInit(EventArgs e)
        wc.InitializeDataSource += new Infragistics.WebUI.WebCombo.InitializeDataSourceEventHandler(wc_InitializeDataSource);

    void wc_InitializeDataSource(object sender, WebComboEventArgs e)
        e.Combo.DataSource = TestClass.SelectAll().Tables[0].DefaultView;
        e.Combo.DataTextField = "Name";
        e.Combo.DataValueField = "ID";

    protected void Page_Load(object sender, EventArgs e)
        // *** To use DataSourceID comment out InitializeDataSource subscription
        // in OnInit override and uncomment the 3 lines below
        //wc.DataSourceID = "ObjectDataSource1";
        //wc.DataTextField = "Name";
        //wc.DataValueField = "ID";

        wc.Editable = true;
        wc.EnableXmlHTTP = true;
        wc.ComboTypeAhead = TypeAhead.Suggest;

    protected void Button1_Click(object sender, EventArgs e)
        // value returns null on second second button click
        object a = wc.DataValue;

And here's the code for the SelectAll method used for the datasource (a simple DataSet)

    public static DataSet SelectAll()
        // TODO: implement SelectAll - this is for testing only
        DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        DataColumn col1 = new DataColumn("ID", typeof(int));
        DataColumn col2 = new DataColumn("Name");

        DataRow row1 = dt.NewRow();
        row1[col1] = 1;
        row1[col2] = "Name 1";

        DataRow row2 = dt.NewRow();
        row2[col1] = 2;
        row2[col2] = "Name 2";

        return ds;

Now when running the page, this is what happens:

1. page loads for the first time

2. select an item in the combo, then  click button  (thus 1st postback)

3. notice that wc.DataValue is retrieved correctly

4. after the page renders, click the button again (don't touch/change combo) (thus 2nd postback)

5. wc.DataValue returns null (at least in my case)

Furthermore, when I use DataSourceID instead of the InitializeDataSource approach, the problem doesn't occur. I'm not sure if I'm missing something.

Hope someone can verify this behavior if this is indeed an issue?