I have an advanced banded gridview inside a usercontrol which has different tab pages inside it.
I'm trying to find the specific datasource/datatable which is currently displaying.The following both return a table but it returns the same table irrespectively on which tab page I currently have selected.
((GridView) sender).DataSource;
((GridView) sender).DataController.ListSource;
The closest I could get was using a masterRowExpanded event and doing the following inside it:
((GridView) sender).GetRelationName(e.RowHandle,e.RelationIndex)
and this returned the name of the tab page I was currently on. Any ideas on how to retrieve the source would be greatly appreciated.
After struggling for a while I managed to get it, inside the masterRowExpanded event I used:
GridView gv = sender as GridView;
AdvBandedGridView abgv = (AdvBandedGridView)(gv.GetDetailView(e.RowHandle,RelationIndex));
Then the advanced banded gridview had the datasource I was looking for.
Related
I have a page for searching when I write my name for example in textbox it will search and display the results in a GridView. I'm using an EntityDataSource with a QueryExtender so I didn't write any code in C#.
The problem is: in the GridView I have a hyperlink when I click it, it will go to another page, ok fine then when I return to the previous page the GridView does not show the results of the search when I was left because of the postback (update panel) it show the whole data from EntityDataSource.
I think I have to use session but I don't know how I can do it, I mean how I can save the GridView in session and how I can retrieve it in page_load.
I have a grid view displaying search results.
Once a field is selected, the data should be displayed in text boxes.
What's the code to fill text boxes when a row of a data grid view is clicked?
I've tried the code that is shown below. It returns an error.
TextBox1.Text = GridView1.SelectedRow[0].Cell[1].Value.ToString();
Index of Currently Selected Row in DataGridView
There you have all you want.
Next time try to use google, or search on that site, before you ask.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview(v=vs.110).aspx
Gridview has lot of events associated with it. based on the location of the text boxes, you may want to use RowEditing event or SelectedIndexChanged event.
I am working on asp.net user control. I have used a gridview and a formview control.
on selecting a row in gridview it will hide the panel containing the grid and will display the panel containing the form view which is using the Grid's selected value as its key value and form loads in edit mode. for some extra use i had to place a checkbox list control in my form view control. and used SQL datasource to fetch data from databese to chkbox list. and used the same data key as formview control. Now my form view control works properly but my Checkbox list is not working properly as it cant get the selected value from grid view.
Thanks in advance for help.
You should bind your CheckBoxList on the DataBound event of your FormView.
Since you would need the same data key, you could use the DataKey property of the FormView.
If any additional data fields are required, you always have the DataItem property.
Done in this order, your CheckBoxList should work as expected.
I used a session variable and it worked for me.
i used a session variable to store the selected value of grid in its selected index changed event and then used it as key value in checkbox list.
I have a couple GridViews that are dynamically created and placed into a PlaceHolder. When I mouse over the Select button, it shows __doPostBack('ctl00$bodyPlaceHolder$ctl0X','Select$Y'), where X = what I think is the GridView/Control index for the page and Y = row number of that GridView.
Since it is dynamically creating the GridViews, it makes sense that names them ctl0X, but on the PostBack how do I use this information?
I wouldn't even have this problem if adding the SelectedIndexChanged EventHandler worked, but it never gets called.
I found one other question like this, but the answer involved adding a GridView within my GridViews, which would also have to be dynamic, which brings me back to the original problem.
Edit
Okay, so I set gridViewDynamic.ID = "blahblah" + r.LastName, thus giving each GridView a unique name, so on mouseover in the page I get __doPostBack('ctl00$bodyPlaceHolder$blahblahSmith',Select$Y, I still can't access the items on PostBack because they no longer exist. So, I added the same GridView creation code to an if(IsPostBack), then called GridView gView = (GridView)this.Page.FindControl(blahblahSmith). Great, gView isn't null. But all the data in the rows are. Calling gView.Rows[0] returns null.
Use Page.FindControl("TheNameYouGaveTheDynamicGridView")
GridView grid = Page.FindControl("TheNameYouGaveTheDynamicGridView") as GridView;
If you are using MasterPages, you need to take a different approach to find the control on the page, but it is the same premise.
How to bind the gridview control to treeview , when user click for the + symbol the gridview has to display.. like tree structure hold the gridview data
Thank You
A treeview holds text natively. It is not designed to hold object data in the fashion you're looking for. To achieve this effect you might be better served by nesting a gridview in a gridview with the plus symbol being in the left column as a link/imagebutton and the title or caption in the right column. When the button is clicked you can enter "edit" mode to bring up the edit template, and inside that template can be a separate gridview control that would be bound to the specific data in question. Then click the linkbutton again (which would have been changed to a minus I assume), you could exit edit mode and return to normal. The disadvantage would be that only one row would be able to be open at a time, but that could be worked around by using the regular item template and using viewstate properties to manage row states.