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;
Related
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 GridView ItemTemplate column in which I have two controls .. DropDownList and a LinkButton. I want to show the selectedItem of DropDownon LinkButton. I am easily able to do so through code behind from selected index changed event. But the problem is that I am not able to maintain the state of the linkbutton when I add a new row on a button click. (because it is not bound to any datasource)
Anyways, can I bind LinkButton with the selected Value of the Dropdown? Something like:
Eval(drp1.SelectedItem.ToString())
If DropDownList is databound from another table, you can add the "Text Value" of the DropDownList from database and display its value to LinkButton.
For example:
If I've a table holds countries and DropDownList to display them, and I've another table storing country Id. In your scenario you can add Inner Join to your select query and display country name in LinkButton text.
I've got a Gridview that lists some SQL data.
And i've got a Formview setup with edit template.
I then want a LinkButton in Gridview, to open edit in formview, with the selected entry in gridview.
I've got this to capture my edit command from Gridview, but how i then trigger my Formview i dont know?
public void newsEdit_Command(Object sender, CommandEventArgs e) {
//Trigger formview edit from here...
//e.CommandArgument contains my ID of the selected row in gridview.
}
In the way you want, i think it is not possible.
You can do it in a simple way as:
1) Show Data in a grid view, When a user selects a row in the grid view, show that row data in the form view ( or you can use a details view )
2) After displaying data in form view, Now edit it's row.
I need to give color of gridview on some condition in datatable. The column is NOT added in gridview but is present in datatable. It checks that if country is USA the color the row as green.
The setting can be done from gridview row databound but not sure how to access the datatable column in rowdatabound.
Thanks!
You cant access Datatable once u assigned it to grid as Datasource for that column as it is not added to grid.
You can add same column in gridview wth visible=false so that u can access it in rowdatabound event of grid and accordingly change color.
Hope this help.
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;