4 Replies - 1964 Views - Last Post: 11 April 2013 - 12:39 PM Rate Topic: -----

#1 sarathi_57  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-April 13

datagrid within a datagrid/datagrid within a datalist in aspx page

Posted 07 April 2013 - 04:01 AM

Hi,

I am new for .Net web page development.

I have a role table as shown in the attached screenshot. The different roles have different activities and activity description.
Attached Image

I need to design a data-grid within a data-grid or a data-grid within a data-list to show the output as shown in the attached output-webpage screenshot.
Attached Image

I require some help in how to design the required data-grid.

Any help is much appreciated.

Note: I am using visual Studio.Net 2008 and Access 2007 as database

Thanks
Sarathi

Is This A Good Question/Topic? 0
  • +

Replies To: datagrid within a datagrid/datagrid within a datalist in aspx page

#2 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1182
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: datagrid within a datagrid/datagrid within a datalist in aspx page

Posted 10 April 2013 - 11:32 AM

Soooo.... what are you looking for from us? Free code? We don't do that here. What have you tried?
Was This Post Helpful? 0
  • +
  • -

#3 sarathi_57  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-April 13

Re: datagrid within a datagrid/datagrid within a datalist in aspx page

Posted 10 April 2013 - 12:55 PM

View Posth4nnib4l, on 10 April 2013 - 11:32 AM, said:

Soooo.... what are you looking for from us? Free code? We don't do that here. What have you tried?




public partial class Default6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection SqlCon2 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Murugasarathi\\Documents\\Visual Studio 2008\\WebSites\\WebSite1\\App_Data\\Test.accdb");
OleDbCommand SqlCom2;

GridView dgChildren = new GridView();

SqlCom2 = new OleDbCommand("SELECT [Activity], [Activity_Description],[Percentage] FROM [Table1]", SqlCon2);


if (SqlCon2.State != ConnectionState.Open)
{
SqlCon2.Open();
}

OleDbDataAdapter ada = new OleDbDataAdapter(SqlCom2);


//

GridView gv = new GridView();
gv.ID = "ID1";
gv.AutoGenerateEditButton = false;
gv.AutoGenerateSelectButton = false;
gv.AllowSorting = true;
gv.AllowPaging = true;


BoundField field = new BoundField();
field.DataField = "Activity";
field.HeaderText = "Activity";
gv.Columns.Add(field);

field.DataField = "Activity_Description";
field.HeaderText = "Activity_Description";
gv.Columns.Add(field);

//ada.Fill(ds);
DataSet ds = new DataSet();
// ada.SelectCommand = SqlCom2;
ada.Fill(ds, "Test");
gv.DataSource = ds.Tables["Test"];
gv.DataSource = ds;
gv.DataBind();

}

}



Actually i am trying several ways like a datagrid with table and also a datagrid to generate dynamically. I didnt wanted others to do free coding for me.

I just wanted someone to help me with the design. Like how to proceed or what controls to be used to achieve this.

Anyway thanks for looking into the post :)

Regards
Sarathi
Was This Post Helpful? 0
  • +
  • -

#4 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1182
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: datagrid within a datagrid/datagrid within a datalist in aspx page

Posted 11 April 2013 - 07:34 AM

You don't need to do all of that newing up of GridViews in your code behind. Drop a GridView onto your .aspx page, drop a SQLDataSource onto your .aspx page (and configure it), and then set the GridView's DataSource to your SQLDataSource.
Was This Post Helpful? 0
  • +
  • -

#5 sarathi_57  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-April 13

Re: datagrid within a datagrid/datagrid within a datalist in aspx page

Posted 11 April 2013 - 12:39 PM

Hi

Thanks for the reply. Actually i need to generate the gridview dynamically like the one i have showed in the screenshot.

I have done some modifications and now i am able to get the ouput as one gridview below the other gridview. but they are all clustered together. I want to show each gridview with some line spaces in between, I am still not able to achieve this.

can we add a New line space between 2 gridview? if so how to do that?




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Data;

public partial class Default7 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection();

OleDbConnection SqlCon1 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Murugasarathi\\Documents\\Visual Studio 2008\\WebSites\\WebSite1\\App_Data\\Test.accdb");

if (SqlCon1.State != ConnectionState.Open)
{
SqlCon1.Open();
}

OleDbDataAdapter da = new OleDbDataAdapter("SELECT DISTINCT [ROLE],sum(People_Involved) as FTES FROM [Table1] group by ROLE", SqlCon1);
DataTable dt = new DataTable();

da.Fill(dt);


// Now iterate through the table and add your controls
for (int i = 0; i < dt.Rows.Count; i++)

{
Table table = new Table();
table.ID = "Table" + i;
Page.Form.Controls.Add(table);

TableRow row = new TableRow();
TableCell cell = new TableCell();
TextBox tb = new TextBox();

// Set a unique ID for each TextBox added
tb.ID = "TextBoxRow_" + i;
tb.Text = "Role: " + i;
tb.BorderStyle = 0;
// Add the control to the TableCell
cell.Controls.Add(tb);
// Add the TableCell to the TableRow
row.Cells.Add(cell);
// Add the TableRow to the Table
table.Rows.Add(row);


OleDbDataAdapter da1 = new OleDbDataAdapter("SELECT DISTINCT [ROLE],sum(People_Involved) as FTES FROM [Table1] where [ROLE] = '" + dt.Rows[i][dt.Columns[0].ToString()].ToString() + "' group by ROLE", SqlCon1);
GridView gv = new GridView();
gv.ID = "ID2" + dt.Rows[i][dt.Columns[0].ToString()].ToString();
gv.AutoGenerateEditButton = false;
gv.AutoGenerateSelectButton = false;
gv.AllowSorting = false;
gv.AllowPaging = false;

DataSet ds = new DataSet();
da1.Fill(ds,"Test");
gv.DataSource = ds.Tables["Test"];
gv.DataSource = ds;
gv.DataBind();
gv.Width = 500;
Page.Controls.Add(gv);

OleDbCommand SqlCom1 = new OleDbCommand("SELECT [Activity], [Activity_Description],[Percentage] FROM [Table1] where [ROLE] = '" + dt.Rows[i][dt.Columns[0].ToString()].ToString() + "'", SqlCon1);

if (SqlCon1.State != ConnectionState.Open)
{
SqlCon1.Open();
}

OleDbDataAdapter ada = new OleDbDataAdapter(SqlCom1);

//

GridView gv1 = new GridView();
gv1.ID = "ID1" + dt.Rows[i][dt.Columns[0].ToString()].ToString();
gv1.AutoGenerateEditButton = false;
gv1.AutoGenerateSelectButton = false;
gv1.AllowSorting = false;
gv1.AllowPaging = false;

DataSet ds1 = new DataSet();
ada.Fill(ds1, "Test1");
gv1.DataSource = ds1.Tables["Test1"];
gv1.DataSource = ds1;
gv1.DataBind();
gv1.Width = 500;
Page.Controls.Add(gv1);


}
}



public override void VerifyRenderingInServerForm(Control control)
{
//
}
}







I have attached the screenshot(current output) that i have achieved till now. But i need to get the output as shown in the screenshot (Required output). I am struggling to add some free space between the gridview or to add some label between the gridview.

But for some reason whatever i added are grouped together at the top of the page.

Any help is much appreciated.

Thanks,
Sarathi

Attached image(s)

  • Attached Image
  • Attached Image

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1