?
Solved

URGENT - Master/Details Datagrid

Posted on 2006-10-20
5
Medium Priority
?
196 Views
Last Modified: 2012-08-13
Experts,
    I've been fighting this for days now, and I still have not found the solution I'm looking for. What I would like to achieve is this: One datagrid with category information, and a child row that appears underneath the parent row displaying all the inventory items related to the parent row. Here's my db setup...

tblCategories:
ID (PK)
Prod_Type
Prod_Make
Prod_Model

tblInventory
ID (FK)
Prod_Location
Prod_Quantity

Does anyone know how I could setup an asp.net (vb) 1.1 datagrid to display this information how I want? It would be awesome if I could also edit the child rows and save back to the db... but if that can't happen I would be happy with just viewing the grid how I would like. Thanks in advance!!!

Jason
0
Comment
Question by:Yeavis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:jnhorst
ID: 17776968
Jason...

The first shot at this that I would take is to use a DataList for the categories.  In a data list you can put HTML into the item template to show for each category record.  What you could do is put an html table in the item template.  In the first table row, place controls to show the type, make, model and a regular html hyperlink (not the server control).  You will probably need some control that you set the display style to none that contains the category id.

Then in the second table row, do something like this:

<tr style="display:none">
     <td>...your data grid here </td>
</tr>

That regular html hyperlink in the first row, then, would call a JavaScript function to toggle the display style of the second row between an empty string (visible) and 'none'.

The data list has an OnItemDataBound event.  In this event you would get the category id from the hidden control in the top table row and query for the inventory and bind your datagrid to that data.

The main down side to this approach is that you cannot page a DataList, but otherwise this should work.

John

0
 

Author Comment

by:Yeavis
ID: 17777053
John,
   Thanks for the response. I see where you're coming from in your approach to the answer for this problem, however I have seen it done using a datagrid. My memory escapes me but I viewed a tutorial on this no later than a month ago.. and now I can't find that page again!! Go figure.. anyway, I want to go this route because it would be cleaner for the end user and it wouldn't require me to have two grids. If you have any further input, please feel free...

Jason
0
 
LVL 10

Accepted Solution

by:
jnhorst earned 2000 total points
ID: 17777824
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17778787
hi,

you could keep the datagrid, add a <br/><div in the column tag with the some label controls and mark the div as display:none as john suggested and add add a toggle js function in the itembound event eg I had a image to toggle a calendar control in the grid

    protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            try
            {
                Image im = (Image)e.Row.Controls[0].Controls[1];
                Label lb = (Label)e.Row.Controls[0].Controls[3];

                if (lb.Text.Length > 0)
                    Image1.Visible = true;

                lb.Style["Display"] = "none";
                im.Attributes.Add("onmouseover", "ToggleCal('" + lb.ClientID.ToString() + "');");
                im.Attributes.Add("onmouseout", "ToggleCal('" + lb.ClientID.ToString() + "');");
            }
            catch (Exception me)
            {
            }
        }
    }

toggle java that i used from sammy


<head runat="server">
    <title>Untitled Page</title>
    <link type="text/css" href="StyleSheet.css" media="all" rel="Stylesheet" />
    <script type="text/javascript">

function getObj(name)
{
  if (document.getElementById)
  {
        this.obj = document.getElementById(name);
      this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
      this.obj = document.all[name];
      this.style = document.all[name].style;
  }
  else if (document.layers)
  {
         this.obj = document.layers[name];
         this.style = document.layers[name];
  }
}

function ToggleCal(c){//Toggle control by row event

if(document.getElementById('' + c + '').style.display=='none')
{
document.getElementById('' + c + '').style.display='block';
}
else
document.getElementById('' + c + '').style.display='none';
}
function ToggleOff(c){//Toggle control off
document.getElementById('' + c + '').style.display='none';
}
function ToggleOn(c){//Toggle control on
document.getElementById('' + c + '').style.display='block';
}
</script>

</head>
0
 

Author Comment

by:Yeavis
ID: 17781368
Awesome... thanks for all the help guys!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question