您好我试图以编程方式将值设置为我的ReportTelerik而没有链接到数据库我使用我需要的数据构建DataSet并将其设置为我的DataSource。但是它无法正常工作我可以设置我的构建中的值数据集。
这里我构建了我的数据集
static DataSet GetAllData()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("Product");
dt.Columns.Add(new DataColumn("Name", typeof(string)));
dt.Columns.Add(new DataColumn("ProductNumber", typeof(string)));
dt.Columns.Add(new DataColumn("Product", typeof(string)));
DataRow dr = dt.NewRow();
dr["Name"] = "Vova";
dr["Name"] = "Dany";
dr["Name"] = "loopy";
dr["ProductNumber"] = "1";
dr["ProductNumber"] = "2";
dr["ProductNumber"] = "3";
dr["Product"] = "Car";
dr["Product"] = "Dor";
dr["Product"] = "Injector";
dt.Rows.Add(dr);
ds.Tables.Add(dt);
return ds;
}
这里我设置了数据
var objectDataSource = new Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = GetAllData();
ReportTelerik report = new ReportTelerik();
report.DataSource = objectDataSource;
我的ReportTelerik课程(未完整)
partial class ReportTelerik
{
#region Component Designer generated code
/// <summary>
/// Required method for telerik Reporting designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
Telerik.Reporting.Group group1 = new Telerik.Reporting.Group();
Telerik.Reporting.Drawing.StyleRule styleRule1 = new Telerik.Reporting.Drawing.StyleRule();
Telerik.Reporting.Drawing.StyleRule styleRule2 = new Telerik.Reporting.Drawing.StyleRule();
Telerik.Reporting.Drawing.StyleRule styleRule3 = new Telerik.Reporting.Drawing.StyleRule();
Telerik.Reporting.Drawing.StyleRule styleRule4 = new Telerik.Reporting.Drawing.StyleRule();
this.labelsGroupFooterSection = new Telerik.Reporting.GroupFooterSection();
this.labelsGroupHeaderSection = new Telerik.Reporting.GroupHeaderSection();
this.textBox1 = new Telerik.Reporting.TextBox();
this.pageHeader = new Telerik.Reporting.PageHeaderSection();
this.reportNameTextBox = new Telerik.Reporting.TextBox();
this.pageFooter = new Telerik.Reporting.PageFooterSection();
this.currentTimeTextBox = new Telerik.Reporting.TextBox();
this.pageInfoTextBox = new Telerik.Reporting.TextBox();
this.reportHeader = new Telerik.Reporting.ReportHeaderSection();
this.titleTextBox = new Telerik.Reporting.TextBox();
this.reportFooter = new Telerik.Reporting.ReportFooterSection();
this.detail = new Telerik.Reporting.DetailSection();
this.textBox2 = new Telerik.Reporting.TextBox();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
//
// labelsGroupFooterSection
//
this.labelsGroupFooterSection.Height = Telerik.Reporting.Drawing.Unit.Inch(0.28125D);
this.labelsGroupFooterSection.Name = "labelsGroupFooterSection";
this.labelsGroupFooterSection.Style.Visible = false;
//
// labelsGroupHeaderSection
//
this.labelsGroupHeaderSection.Height = Telerik.Reporting.Drawing.Unit.Inch(0.40000000596046448D);
this.labelsGroupHeaderSection.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.textBox1});
this.labelsGroupHeaderSection.Name = "labelsGroupHeaderSection";
this.labelsGroupHeaderSection.PrintOnEveryPage = true;
//
// textBox1
//
this.textBox1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.02083333395421505D), Telerik.Reporting.Drawing.Unit.Inch(0D));
this.textBox1.Name = "textBox1";
this.textBox1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(6.4166665077209473D), Telerik.Reporting.Drawing.Unit.Inch(0.40000000596046448D));
this.textBox1.StyleName = "PageInfo";
//
// pageHeader
//
this.pageHeader.Height = Telerik.Reporting.Drawing.Unit.Inch(0.44166669249534607D);
this.pageHeader.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.reportNameTextBox});
this.pageHeader.Name = "pageHeader";
//
// reportNameTextBox
//
}
}
我在这里缺少的是否需要在ReportTelerik类中声明一些元素?,我可以设置我构建的数据集中的值。
答案 0 :(得分:0)
我发现你需要添加这个
this.textBox1.Value="=Name";