I have a ASPxGridView with a combobox column. Now i want to bind a datatable to that combobox, this datatable is made in the code behind so it does not exist at the moment the gridview is being made. instead i have to bind the datatable to the combobox in the HtmlEditFormCreated event.
I tried :
ASPxGridView4.FindControl("PNaam");
But that does not seem to allow me to bind the datatable to it. So i was wondering how can i bind the datatable to the combobox column inside the HtmlEditFormCreated event?
Handle the Page_Init event as shown below to bind the column's editor to your DataTable:
(ASPxGridView1.Columns["SomeFieldName"] as GridViewDataComboBoxColumn).PropertiesComboBox.DataSource = yourDataTable;
Related
i use a datatable as datasource of my bindingsource.
The columns have the following order and ordinals:
Before setting the datasource of datagridview
When I assign the bindingsource to the datasource property of my datagridview the
ordinals changes:
Afer settting the datasource of datagridview
The last column ("Gesamt") gets the ordinal 0.
How can I avoid this effect?
This is the relevant code:
BsData.DataSource = myPR.PR_Data; //PR_Data is the datatable ,
//BsData is the bindingsource
dgvSchoolGrade.DataSource = null; //dgvSchoolGrade is the Datagridview
//Before
dgvSchoolGrade.DataSource = BsData;
//After
Thank you very much in advance!
Sascha
i have a dropdownlist in a column in a gridview. This dropdwon already had two items in it i.e Close/Open. What i require is that I bind the gridview to a dataset, all i want is for the dropdown to show the value that is in the dataset.(open or close)
I got the answer. Its a bit of an work around. You cannot directly bind the gridview dropdownlist to the dataset column. What I did instead was, I bound the Dataset column to a hiddenfield and then in Rowdatabound event i assigned the dropdown.selectedvalue to the hiddenfield.value.
Works Perfectly...Thanks everyone.
I have a DataGridView that is populated using a list.
During Runtime, the user can filter the data by entering data in a textbox. I am able to do the filtering part.
But the problem i am facing is when i change the datasource to the new datasource in the Textbox1_TextChanged event, the datagridview is populating the data with rows equal to the number of rows in my new datasource but each row is replica of the first row.
When I check the DataSource of the datagridview it has the data of the new DataSource.
So when I check the row selected in the datagridview_doubleclick event, the DataBoundItem gives me the exact object that it should give according the to new datasource.
What might have gone wrong??
Maybe I am wrong, but do you need to clear the DataGridView when binding to a new datasource.... my binding skills are lacking....
Try clearing the DataGridView, before changing the datasource like :
DataGridView.Rows.Clear();
I am having a gridview control and in the edit template of the gridview control., inside the edit template I need another grid view control., I am having a bound field in the second gridview which always binds to the selected value in the gridview 1 .,
So can somebody tell me in which event and all i have to do the databind for the gridview 2.
I am having an sqldatasource for the gridview2.
Thanks
i think the event you are looking for is "row_command" of your main gridview. in row_command event, you can get your value from the row that you selected, then find your gridview inside your row, and give its datasource.
i cant test it now, but should be something like this
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = MainGridView.Rows[index];
Gridview dv = row.FindControl(“yourGridViewId”);
dv.DataSource = yourdatasource;
I am trying to bind Data to a DataGridView, where the DataGrid already have columns, and if i have columns like TextBox columns it works perfectly, but the problem is if i have columns like ComboBox.
I am trying to do this in Windows Forms. I am just trying to understand the problem when i load the data to a DataTable from the Database. For example, i am loading the Data from the Database to a Datatable and then i set it as DataSource of the DataGridView, but how i can put the data in customized columns where columns are of ComboBox type?
Try this link.
Binding a Combobox control to a separate source within a DataGrid
Binding data with comboBox in DataGridview
DataGridViewComboBoxColumn Class
combobox column in datagridview after binding the table
Regards