I am setting datasource for a webcombo on page_Init coz we are loading controls dynamically on the form.
Dim ddl As Infragistics.WebUI.WebCombo.WebCombo = New Infragistics.WebUI.WebCombo.WebCombo ddl.ID = String.Format("ddl{0}", row("IdWorkItemField").ToString) ddl.DataValueField = "IdWorkItemListBox" ddl.DataTextField = "TxListValue" ddl.EnableXmlHTTP = True ddl.DataSource = GetAllowedValues(DirectCast(row("IdWorkItemField"), Integer)) AddHandler ddl.InitializeLayout, AddressOf ddl_InitializeLayout AddHandler ddl.InitializeDataSource, AddressOf ddl_InitializeDS AddHandler ddl.SelectedRowChanged, AddressOf DDL_SelectedRowChanged ddl.DataBind()
ddl.value = GetDefaultValue(DirectCast(row("IdWorkItemField"), Integer)) '(To set the value ddl needs to be loads thats why we do ddl.DataBind on the above line)
We are using Infragistics2.WebUI.WebCombo.v9.1, Version=9.1.20091.1015
First time it loads fine. but any postback causes columns to duplicate (Not Rows.. just columns with empty values).
What am I doing wrong? I narrowed it down to ddl.DataBind method, If I skip that line in debugger on postbacks then columns don't get repeated). What can I do to fix the problem?
For now I added logic before doing .Databind (Only binding it first time)
If Not Page.IsPostback then ddl.DataBind End if
But still like to know why columns are being repeated.
Hi,
Just a guess but I think your DataBind in in the wrong place. Page_Init is the place for adding your event handlers, but not binding your data. I would move it to the Page_Load (just like yours, only on first load, not postback).
Also add it to the InitializeDataSource event for that WebCombo, you also need to set the dataSource and handle your data during the postback (like saving it to session, and loading it from session in this event).
Hope this helps,
PenPal1999