Assigning dynamic store to a dynamic combobox.
I can create a store and a combobox on the codebehind. I am just not sure how I assign this store to the combobox.
Code:
//Add Subject Combobox
ComboBox comboSubject = new ComboBox();
comboSubject.FieldLabel = "Subject";
// it would accept xStore to comboSubject.Store (Cannot implicitly convert type 'Ext.Net.Store' to 'Ext.Net.StoreCollection')
comboSubject.Store = xStore();
comboSubject.ValueField = "SubjectCode";
comboSubject.DisplayField = "Description";
comboSubject.AnchorHorizontal = "95%";
comboSubject.AddTo(subContainSubject);
//Create a Store
private Ext.Net.Store xStore()
{
//Get the data for the store
SubjectBLL subjectBLL = new SubjectBLL();
List<Subject> subjectList = new List<Subject>();
subjectList = subjectBLL.getAllSubjects();
//Create the store
JsonReader _jsonReader = new JsonReader();
Store xStore = new Store();
_jsonReader.Fields.Add("Description");
_jsonReader.Fields.Add("SubjectCode");
xStore.Reader.Add(_jsonReader);
xStore.DataSource = subjectList;
xStore.DataBind();
return xStore;
}
Not sure how I get this working.:confused:
Works Perfect! Thank you.
Works Perfect! Thank you.
Dynamic Store and Combobox
Hi Vladimir,
I'm trying to fill combobox using dynamic store but unfortunately, I'm not being able to do it.
Here is my code:
Code:
Public Sub FillDropDown(ByRef DropDownID As ComboBox, ByVal DataDisplayField As String, ByVal DataValueField As String, ByVal strSQLQuery As String)
Dim dt As DataTable = SomeObject.GetDataTable(strSQLQuery)
Dim cmbStore As New Ext.Net.Store
cmbStore.ID = "comboStore"
Dim jReader As New JsonReader()
jReader.Fields.Add(DataDisplayField)
jReader.Fields.Add(DataValueField)
cmbStore.Reader.Add(jReader)
cmbStore.DataSource = dt
cmbStore.DataBind()
'aspxPage.Controls.Add(cmbStore)
DropDownID.StoreID = cmbStore.ID
''DropDownID.Store.Add(cmbStore)
DropDownID.DisplayField = DataDisplayField
DropDownID.ValueField = DataValueField
DropDownID.DataBind()
End Sub
Please also note that I have this function in my project which is responsible to bind data for comboboxes on several .aspx pages and thus, I have passed Combobox with Ref parameter. I have also tried to pass an .aspx page with reference parameter to add store to the control collection of page but I did not work either (you can see the commented code). I have debugged this code and I'm getting value in my DataTable as well.
What am I doing wrong here ??
Thanks