Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 29, 2010 03:53 PM by oluts
Jun 26, 2010 04:44 PM|LINK
Please i am trying to find out if its possible to select a row in a parent gridview and once that is selected....all the other rows in the Parent gridview is invisible...and the one i am working with is only seen on the gridview at that time.
Jun 26, 2010 05:08 PM|LINK
you can hide the other rows by setting Visible as false to other rows.
can you explain the requirement little more pls.
Jun 26, 2010 05:32 PM|LINK
I currently have a gridview binded to the database which is the parent and when its selected it post the child based on the ID.Now i have couple records on the gridview and once i select the one i need i want the others to be invinsible. so the one i am
working on will show alone. using visible="flase" will work for the whole Gridview,
I hope you understand.
Jun 26, 2010 06:42 PM|LINK
What I understood from your description was
You are using a nested gridview in which you are doing a postback to load some child gridview and once you select the row in the child gridview,
You want to hide the others.
You can do like this
find the Child gridview in the code behind and in the selectedIndexChangedEvent,
find the Gridviewrow selected and then
it will get all the rows in teh child gridview and hide all rows except the row selected.
Correct me if I understood your requirement wrong.
Jun 27, 2010 12:15 AM|LINK
Yeah... You kind of onpoint but not quite... You are right about the nested grid. and i can only see my child grid based on the selection i make on the parent grid. Now.... once i select a row from the Parent grid.....it will automatically show me the child
grid based on the selection
Now my point is... if i have five records on the parent grid and select one of the records.... i only want the selected row to show instead of all the other 4.... Currently its highlights the selected record. but i will like to make the other records invisible
while another record is seleted....
I hope i explained better this time around
Jun 27, 2010 02:24 PM|LINK
In the Parent gridview selected index change event,
get the row index from e.CommandArgument and then you can do like this
That should get all rows except selected row and hide other rows.
Jun 27, 2010 08:13 PM|LINK
Thanks Sansan... Am so confused about your syntax.... i used it and it game me errors. The only thing i changed was the gridviewparent to its name on my code....My gridview name is "GridViewAll".... Could you please help write based on my gridview name....
my event handler is "Protected Sub GridviewAll_SelectIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs).....Thanks
Jun 27, 2010 08:34 PM|LINK
u can try like this
protected void GridViewAll_SelectedIndexChanged(object sender, EventArgs e)
Where(a => a.RowIndex != GridViewAll.SelectedIndex).
ToList().ForEach(b => b.Visible = false);
Jun 27, 2010 08:56 PM|LINK
Thanks Again Sansan, just so you know .. i am using asp 3.5 so my handler will not accept void but sub... when i put in the code... it does not allowe <GridviewRow> and the "a" and "b". i guess it needs to be declared. but i am woundering if it as to do
with the event handler. What do you think
Jun 27, 2010 09:03 PM|LINK
If you are using C#,
add using System.Linq;
If you are using VB,
add Imports System.Linq;
Protected Sub GridViewAll_SelectedIndexChanged(sender As Object, e As EventArgs)
GridViewAll.Rows.OfType(Of GridViewRow)().ToList().Where(Function(a) a.RowIndex <> GridViewAll.SelectedIndex).ToList().ForEach(Function(b) b.Visible= False)
Hope this helps