julio15 Posted September 21, 2007 Report Share Posted September 21, 2007 Hello, How can I dynamically in C# create an expandable grid (detail table)from Grid1 (master table)? Are these two grids related through theprimary key? 2. How can I change the message: No data in Grid?. 3. When I do a copy of the data contained in Grid1, and I want to see the next page I encounter the following difficulty: - The operation takes forever to materialize and the message : "it is taking a long to process your request..." comes on the screen. How can I avoid such a problem? Thanks, julio Quote Link to comment Share on other sites More sharing options...
AngelR Posted September 24, 2007 Report Share Posted September 24, 2007 Expandable areas like Sidebars, are based on templates though when you set an Expandable area at design time, Grid FX is automatically implementing an ASP.NET ITemplate Interface. Therefore, to create an Expandable area programmatically you'll have to write the code to implement an ASP.NET ITemplate Interface first. Shortly we Quote Link to comment Share on other sites More sharing options...
julio15 Posted September 27, 2007 Author Report Share Posted September 27, 2007 Hi! Firstof all, thank you for your answers. In thecases of creating dynamically the Grids, both the master table and the detailtable, up to a second level, already function properly. At present,I am using IIS and two tables (master table and detail table) to carry out atest. Statically, I create Grid 1 with an empty field(NombreProvincia) otherwise I could notcreate Grid 2 as a daughter table. I do all the remaining workdynamically. Given below is the codeshowing the way I configure the Grids: protected void Grid1_Load(object sender, EventArgse) { if (!IsPostBack) { Session["Llamada"] = "Nulo"; String d = Grid1.DataSourceID; Grid1.DataSourceID = ""; NumberField field2 = newNumberField(); NumberField field3 = newNumberField(); FieldColumn col2 = newFieldColumn(); FieldColumn col3 = newFieldColumn(); field2.DataPath = "IndiceRango"; col2.Field = field2; field3.DataPath = "IndiceNacional"; col3.Field = field3; Grid1.Fields.Add(field2); Grid1.Fields.Add(field3); Grid1.Columns.Add(col2); Grid1.Columns.Add(col3); Grid1.DataBind(); Grid1.Fields[0].Title= "Provincia"; Grid1.Fields[1].Title = "Indicerango"; Grid1.Fields[2].Title = "Indicenacional"; ((FieldColumn)Grid1.Columns[0]).Style.Bold = true; // para una solacolumna Grid1.ItemSettings.Style.HorizontalAlign = HorizontalAlign.Center;//para todos los items Grid1.SideBars[0].Side = SideBarSide.Bottom; } } protected voidGrid1_DataBinding(object sender, EventArgs e) { TCtrInterrupcionesinterrupciones = new TCtrInterrupciones(); if(Session["Llamada"].ToString() == "Nulo") { DateTime Fecha1 = newDateTime(); DateTime Fecha2 = newDateTime(); Fecha1 = Convert.ToDateTime("20/02/06"); Fecha2 = Convert.ToDateTime("22/06/06"); DataSetDSInt = interrupciones.ReporteIndiceLineasNV("Nacional",Fecha1, Fecha2, "Circuitos Primarios"); DataView DV = new DataView(); DV =DSInt.Tables[0].DefaultView; Grid1.DataSource= DV; } Session["Llamada"]= "Nulo"; } protected voidGrid1_PageIndexChanging(object sender, GridPageEventArgs args) { String sd = args.ToString(); int t = args.NewPageIndex; Grid1.DataBind(); Session["Llamada"] = "ok"; } protected void Grid2_Load(object sender, EventArgse) { try { int pos = DevolverPosItemExp(); if (Session["Expandido"].ToString()!= "True") { Grid Grid2 = (Grid)Grid1.Items[pos].DetailsCell.FindControl("Grid2"); ConfigurarGrid2(Grid2); Session["Llamada"] = "Nulo"; Session["Llamada"] = "BindingGrid2Exp"; Grid2.DataBind(); Grid2.ItemSettings.Style.HorizontalAlign = HorizontalAlign.Center;//para todos los items Session["Expandido"] = "True"; } else {Session["Expandido"] = "False"; } } catch { Session["Expandido"]= "False"; } } protected void Grid2_DataBinding(object sender, EventArgse) { try { String prueba = Session["PrimeraLlamadaGrid2"].ToString(); } catch { Session["Expandido"] = "False"; Session["PrimeraLlamadaGrid2"] = "True"; } TCtrInterrupcionesinterrupciones = new TCtrInterrupciones(); if (Session["Llamada"].ToString()== "BindingGrid2Exp") { int pos = DevolverPosItemExp(); Grid Grid2 = (Grid)Grid1.Items[pos].DetailsCell.FindControl("Grid2"); String Prov = Grid1.Items[pos].DataValues["NombreProvincia"].ToString(); Grid2.DataSourceID= ""; DateTime Fecha1 = newDateTime(); DateTime Fecha2 = newDateTime(); Fecha1 = Convert.ToDateTime("20/02/06"); Fecha2 = Convert.ToDateTime("22/06/06"); DataSetDSInt = interrupciones.ReporteIndiceLineasNV(Prov, Fecha1, Fecha2, "Circuitos Primarios"); DataView DV = new DataView(); DV =DSInt.Tables[1].DefaultView; Grid2.DataSource= DV; } Session["Llamada"]= "Nulo"; } private voidConfigurarGrid2(Grid Grid2) { Grid2.LayoutType= GridLayoutType.Columnar; Grid2.Motif= GridMotif.Default; Grid2.Palette= GridPalette.Windows; Grid2.EnableFloatingBar= false; Grid2.Selection.Enabled= true; Grid2.Highlighting.Enabled= false; Grid2.Paging.PageSize= 10; Grid2.DataSourceID= ""; TextField field2 = newTextField(); NumberField field3 = newNumberField(); NumberField field4 = newNumberField(); NumberField field5 = newNumberField(); NumberField field6 = newNumberField(); NumberField field7 = newNumberField(); NumberField field8 = newNumberField(); FieldColumn col2 = newFieldColumn(); FieldColumn col3 = newFieldColumn(); FieldColumn col4 = newFieldColumn(); FieldColumn col5 = newFieldColumn(); FieldColumn col6 = newFieldColumn(); FieldColumn col7 = newFieldColumn(); FieldColumn col8 = newFieldColumn(); field2.DataPath = "FechaMes"; col2.Field = field2; field3.DataPath = "IndAnnoAntMes"; col3.Field = field3; field4.DataPath= "PlanMes"; col4.Field = field4; field5.DataPath = "Indice"; col5.Field= field5; field6.DataPath = "IndAnnoAntAcum"; col6.Field = field6; field7.DataPath = "PlanAcum"; col7.Field = field7; field8.DataPath = "IndAcumulado"; col8.Field = field8; Grid2.Fields.Add(field2); Grid2.Fields.Add(field3); Grid2.Fields.Add(field4); Grid2.Fields.Add(field5); Grid2.Fields.Add(field6); Grid2.Fields.Add(field7); Grid2.Fields.Add(field8); Grid2.Columns.Add(col2); Grid2.Columns.Add(col3); Grid2.Columns.Add(col4); Grid2.Columns.Add(col5); Grid2.Columns.Add(col6); Grid2.Columns.Add(col7); Grid2.Columns.Add(col8); Session["PrimeraLlamadaGrid2"] = "False"; } private intDevolverPosItemExp() { int j = 0; foreach (GridItemcurrItem in Grid1.Items) { if (currItem.Expanded) { return j; } j++; } j = -1; return j; } I haveother 2 questions: What can I do to prevent the message Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.