473,320 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Nested GridViews plus DetailsView

Hello,

I'm trying to create a table with 2 nested gridviews and then a
DetailsView on the right. The DetailsView should show the details of
the item selected in the 2nd (nested) GridView:

My "master" table is like this:
A1
A A2
A3

B1
B B2
B3

C1
C C2
C3

When I click on, for example, B2, the detailsview should be updated.
I created the second GridView inside a TemplateField of the first
GridView. Then I added a RowDataBound event handler to set the correct
data source to it:

protected void GridView1_rowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gv =
(GridView)e.Row.FindControl("GridView2");

SqlDataSource sds = new
SqlDataSource(System.Configuration.ConfigurationMa nager.ConnectionStrings["NBIIIS_05ConnectionString"].ToString(),
"SELECT distinct FA_Intitule, fam.FA_CodeFamille,
art.AR_Stat03 FROM F_FAMILLE fam INNER JOIN F_Article art ON
fam.FA_CodeFamille=art.FA_CodeFamille WHERE AR_Stat03='" +
((DataRowView)e.Row.DataItem)["AR_Stat03"].ToString() + "' ORDER BY
art.ar_stat03,FA_Intitule");
gv.DataSource = sds;
gv.AutoGenerateColumns = false;

HyperLinkField hf = new HyperLinkField();
hf.DataTextField = "FA_Intitule";
gv.Columns.Add(hf);

gv.RowDataBound += new
GridViewRowEventHandler(gv_RowDataBound);

gv.DataBind();
}
}

So far so good. However, what should I add as the field for the column
of the 2nd GridView to allow me to update the DetailsView? I tried
ButtonFields() but, because I'm creating the nested GridViews at
runtime, I couldn't figure out how to get the selected item after the
postback. Adding an event handler for RowCommand or SelectedItemChanged
doesn't work, even with EnableViewState as true.

Now, as can be seen, I'm trying HyperLinkFields but I can't set the
NavigateUrl properly, even at the RowDataBound handler of the nested
GridView. This is because I don't know how to access the HyperLinkField
of the row.
Anyway, I don't think this is the best way to do it.

Anyone can help?

Thanks in advance,

Manuel Ricca

Apr 27 '06 #1
0 2761

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Martin | last post by:
Hi, I have a very frustrating problem that I have researched for countless hours to no avail. There are many posts asking very similar things, however none usefull in my situation. I am using VS...
1
by: Roy | last post by:
Hey all. Below is the nested syntax on how to make a "codeless" nested gridview embedded within another gridviews templatefield column. Only problem is that it loads slow. REAL SLOW. There has to...
0
by: luvdairish | last post by:
Controls (in order on page) 1.)GridView - each row is a work order w/ a link for details in the last column 2.)DetailsView - when user clicks on link from above GridView, the details are shown...
0
by: sansie | last post by:
Hi, I have a page which is basically a details view(in inset mode) inside a datalist. The problem is I want to set the field "invoiceID" (of the detailsview) to an invoiceID coming through the...
1
by: Chris | last post by:
I am creating a nested gridview as per the tutorial here (http://msdn2.microsoft.com/en-us/library/aa992038(vs.80).aspx). My gridviews work fine. I have a master gridview containing the customerid....
0
by: titia111 | last post by:
I am new to 2.0 and am using nested gridviews. The first one contains category information, the second is based on a query from a product table. The data is pulling correctly, but the problem is...
3
by: ThatsIT.net.au | last post by:
I'm looking for a very simple nested grid view example. Also I have been creating tables instead of using gridview for complex tasks or just spitting out html from code. Do you recommend using...
2
by: GISmatters | last post by:
I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files...
0
by: omgdork | last post by:
Hi! I'm having trouble on how to proceed with inserting data that are in parent and child gridviews. I have a gridview with nested gridviews that looks like this: ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.