Telerik中的动态报告 [英] Dynamic Reports in Telerik

查看:63
本文介绍了Telerik中的动态报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我是Kuldeep,尝试通过此代码创建动态报告但显示空白。

请帮助或建议我我犯了什么错误。这是正确的代码吗?我可以在哪里找到它的解决方案或帮助。

Hi,

I am Kuldeep, trying to create dynamic report thru this code but show blank.
Please help or suggest me, what I am making mistake in it. Is it right code? And where I can find its solution or help.

private void table1_ItemDataBinding(object sender, EventArgs e)
        {
            dbCon = new SqlConnection(ConfigurationManager.ConnectionStrings["abc"].ConnectionString);
            dbCon.Open();
            dbCon.Close();
            SqlDataAdapter adapter = new SqlDataAdapter("spOrder", dbCon);
            Telerik.Reporting.Processing.Table processingTable = (sender as Telerik.Reporting.Processing.Table);
            Telerik.Reporting.Table table1 = new Telerik.Reporting.Table();
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            processingTable.DataSource = dt;
            Telerik.Reporting.HtmlTextBox textboxGroup;
            Telerik.Reporting.HtmlTextBox textBoxTable;
            table1.ColumnGroups.Clear();
            table1.Body.Columns.Clear();
            table1.Body.Rows.Clear();
            int i = 0;
            foreach (DataColumn dc in dt.Columns)
            {
                Telerik.Reporting.TableGroup tableGroupColumn = new Telerik.Reporting.TableGroup();
                table1.ColumnGroups.Add(tableGroupColumn);
                table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Unit.Inch(1)));

                textboxGroup = new Telerik.Reporting.HtmlTextBox();
                textboxGroup.Style.BorderColor.Default = Color.Black;
                textboxGroup.Style.BorderStyle.Default = BorderType.Solid;
                textboxGroup.Value = dc.ColumnName.ToString();
                textboxGroup.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
                tableGroupColumn.ReportItem = textboxGroup;

                textBoxTable = new Telerik.Reporting.HtmlTextBox();
                textBoxTable.Style.BorderColor.Default = Color.Black;
                textBoxTable.Style.BorderStyle.Default = BorderType.Solid;
                textBoxTable.Value = "=Fields." + dc.ColumnName;
                textBoxTable.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
                table1.Body.SetCellContent(0, i++, textBoxTable);
                table1.Items.AddRange(new ReportItemBase[] { textBoxTable, textboxGroup });

            }
        }



谢谢和问候!

Kuldeep Dwivedi


Thanks and Regards!
Kuldeep Dwivedi

推荐答案

谢谢RaisKazi



问题解决了。

请使用代码查找解决方案步骤,如果有任何想法使其更有意义,请建议我。下面的代码对我有用。

1.首先在报告上拖一个空白表。

2.代码背后: -

Thanks RaisKazi

Problem is solved.
Please find the solution steps with code and if there is any idea to make it is or more meaningful please suggest me. Below code is working for me.
1. Drag a blank table on report first.
2. Code behind:-
private void ReportTry_NeedDataSource(object sender, EventArgs e)
        {
            dbCon = new SqlConnection(ConfigurationManager.ConnectionStrings["abc"].ConnectionString);
            dbCon.Open();
            dbCon.Close();
            SqlDataAdapter adapter = new SqlDataAdapter("spOrder", dbCon);
           
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            table1.DataSource = dt;

            Telerik.Reporting.HtmlTextBox textboxGroup;
            Telerik.Reporting.HtmlTextBox textBoxTable;
            table1.ColumnGroups.Clear();
            table1.Body.Columns.Clear();
            table1.Body.Rows.Clear();
            int ColCount = dt.Columns.Count;
            for (int i = 0; i <= ColCount -1; i++)
            {
                
               
                Telerik.Reporting.TableGroup tableGroupColumn = new Telerik.Reporting.TableGroup();
                table1.ColumnGroups.Add(tableGroupColumn);
                //table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Unit.Inch(1)));

                textboxGroup = new Telerik.Reporting.HtmlTextBox();
                textboxGroup.Style.BorderColor.Default = Color.Black;
                textboxGroup.Style.BorderStyle.Default = BorderType.Solid;
                textboxGroup.Value = dt.Columns[i].ColumnName;
                textboxGroup.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
                tableGroupColumn.ReportItem = textboxGroup;
            
                textBoxTable = new Telerik.Reporting.HtmlTextBox();
                //textBoxTable.Style.BorderColor.Default = Color.Black;
                //textBoxTable.Style.BorderStyle.Default = BorderType.Solid;
                textBoxTable.Value = "=Fields." + dt.Columns[i].ColumnName;
                textBoxTable.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
                table1.Body.SetCellContent(0, i, textBoxTable);
                table1.Items.AddRange(new ReportItemBase[] { textBoxTable, textboxGroup });
            
            }
           
        }

谢谢和Reagdrs!

Kuldeep Dwivedi

Thanks and Reagdrs!
Kuldeep Dwivedi


如果您是注册的Telerik用户,Telerik支持论坛可能会为您提供解决方案。



特里克支持论坛
Telerik Support Forum may provide you solution on this, if you are a registerd Telerik User.

TELERIK SUPPORT FORUMS


这篇关于Telerik中的动态报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆