I am databinding a Combo to a List<T> by setting the DataSource property. I have 2 items and I can see them.
On a click of a button I set the DataSource property to a List<T> of the same type but with 1 item. When I click to view the items I have 2 items instead of 1.
The Rows.Count = 2 but the DataSource.Count has 1.
I have tried setting DataSource to null before assigning it, tried DataBind() after assignment but no luck.
Please help
List<Article.ArticleDataField> mFields = null;
//Add 2 items to mFields
...//Databind
cbXColumn.DataSource = mFields; //2 rows 2 datasource items
//Databind after button clickcbXColumn.DataSource = GetSubList(Sentinel.Data.FilterDefinition.eDatatype.number); //2 rows 1 datasource item
private List<Article.ArticleDataField> GetSubList(Data.FilterDefinition.eDatatype type) { List<Article.ArticleDataField> fields = new List<ArticleDataField>(); if (mFields != null) { foreach (Article.ArticleDataField df in mFields) if (df.DataType == type) fields.Add(df); } return fields; }
Hello
Can you send source ? I will fixed them.
Be Success
Kyaw
I'm in C# and have tried all methods of setting the datasource to null, databind() calls but nothing
Hi Friend
Please try like following.
youcombo.DataSource = Nothingyourcombo.DataSource = YourList
If you have other query, please let me know.