I need to create dynamically a Grid strutucture with 3 level hyerarchy
how can I set the SessionParameters in C#
my code is looking like:
And I´m Calling with:
But the parameters are not being supplied.
how can I set the SessionParameters in C#
my code is looking like:
private void DefineGridStructure(string VQuery1,string VDataKey1,string VQuery2,string VDataKey2) |
{ |
string connString = ConfigurationManager.ConnectionStrings["coelbaConnectionString"].ConnectionString; |
SqlDataSource DataSource1 = new SqlDataSource(connString, VQuery1.ToString()); |
DataSource1.ID = "SqlDataSource1"; |
this.PlaceHolder1.Controls.Add(DataSource1); |
RadGrid RadGrid1 = new RadGrid(); |
RadGrid1.ID = "RadGrid1"; |
RadGrid1.DataSourceID = "SqlDataSource1"; |
RadGrid1.MasterTableView.DataKeyNames = new string[] { VDataKey1 }; |
RadGrid1.Width = Unit.Percentage(98); |
RadGrid1.PageSize = 40; |
RadGrid1.AllowPaging = true; |
RadGrid1.AllowSorting = true; |
RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; |
RadGrid1.PagerStyle.Position = GridPagerPosition.TopAndBottom; |
RadGrid1.PagerStyle.NextPagesToolTip = "Próximas páginas"; |
RadGrid1.PagerStyle.PrevPagesToolTip = "Páginas anteriores"; |
RadGrid1.PagerStyle.NextPageText = "Próxima página"; |
RadGrid1.PagerStyle.PrevPageToolTip = "Página Anterior"; |
RadGrid1.AutoGenerateColumns = true; |
RadGrid1.ShowStatusBar = true; |
RadGrid1.ShowFooter = true; |
RadGrid1.Skin = "Sunset"; |
RadGrid1.MasterTableView.PageSize = 40; |
RadGrid1.MasterTableView.AllowMultiColumnSorting = true; |
if (VQuery2 != "") |
{ |
SqlDataSource DataSource2 = new SqlDataSource(connString, VQuery2); |
DataSource2.ID = "SqlDataSource2"; |
SessionParameter nummes = new SessionParameter("@nummes", System.Data.DbType.Int32,"nummes"); |
DataSource2.SelectParameters.Add(nummes); |
this.PlaceHolder1.Controls.Add(DataSource2); |
//Detail table - Orders (II in hierarchy level) |
GridTableView tableViewOrders = new GridTableView(RadGrid1); |
tableViewOrders.DataSourceID = "SqlDataSource2"; |
tableViewOrders.Width = Unit.Percentage(100); |
tableViewOrders.DataKeyNames = new string[] { VDataKey2 }; |
tableViewOrders.AutoGenerateColumns = true; |
GridRelationFields relationFields = new GridRelationFields(); |
relationFields.MasterKeyField = VDataKey1; |
relationFields.DetailKeyField = VDataKey1; |
tableViewOrders.ParentTableRelation.Add(relationFields); |
RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders); |
} |
this.PlaceHolder1.Controls.Add(RadGrid1); |
} |
And I´m Calling with:
DefineGridStructure("exec sp_totalAnoMes", "nummes", "exec sp_relPorData", "datakey"); |