views:

390

answers:

1

Hello, I have a web form where I have a textbox in which the user will enter the number and pull the information from the table. Now I have developed a xtrareport, where I have to display the data of which the user enters in that textbox which I mentioned earlier. Everything works fine, only I need to just pass the value of the texbox(form1) to the report (form2).

Now what I need is how to pass the textbox value as a parameter to the report and display the report data of the selected number.

A: 
  1. In the Report Designer You should create Report Parameter and use it anywhere in report(for example in report filter).
  2. Before showing report to user you should find parameter in report instance and assign value to it.

here is sample code:

                        using (var report = new XtraReport())
                        {
                            report.Bands.Add(new DetailBand());
                            report.Parameters.Add(new Parameter { Name = "userName",ParameterType = ParameterType.String});
                            report.FilterString = "USER = userName";
                            report.SaveLayout("test.repx");
                        }
                        using (var report = new XtraReport())
                        {
                            report.LoadLayout("test.repx");
                            report.Parameters.First(p => p.Name == "userName").Value = textBox.Text;
                            report.ShowPreviewDialog();
                        }

Notice
It is winform sample. But principles are same. Also it is very simple to pass textbox value to webform via querystring for example.

Sergey Mirvoda
Thank you....for your quick response.. i really appreciate that!! But how to pass textbox value from one webform to other ??
ahmed
Sergey Mirvoda