Hi All
I have Web Application ,I use crystal reports for visual studio.net ,I want reporting with Dataset class , I have form for filter data with control Textbox for assing data ,After that , to bring data filter aready show in crystal reports
Plase introduce source code for reporting
I have Code Example for C Language ,but I am not expert in C Language ,I want apply code c language convert in vb for asp.net and Exchange from control dropdownlist is control textbox
Code sample for C and control dropdownlist
File WebForm1.aspx
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="begin_report2.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="Tahoma">
<asp:DropDownList DataTextField="CustomerID" id="DropDownList1" style="Z-INDEX: 101; LEFT: 209px; POSITION: absolute; TOP: 36px" runat="server"></asp:DropDownList>
<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 51px; POSITION: absolute; TOP: 36px" runat="server" Width="138px">เลือกเมืองที่ต้องการ</asp:Label></FONT></form>
</body>
</HTML>
File WebForm1.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls; namespace begin_report2
{
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected begin_report2.Ds ds1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(ds1);
DropDownList1.DataSource = ds1.Tables[0].DefaultView ;
DropDownList1.DataTextField = "Country";
DropDownList1.DataValueField = "Country";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0,new ListItem("",""));
DropDownList1.Attributes.Add("onchange","if(this.value.length!=0)location.href='report.aspx?country='+this.value");
}
File report.aspx
<%@ Page language="c#" Codebehind="report.aspx.cs" AutoEventWireup="false" Inherits="begin_report2.report" %>
<%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=9.1.3300.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>report</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="report" method="post" runat="server">
<CR:CrystalReportViewer id="CrystalReportViewer1" style="Z-INDEX: 101; LEFT: 7px; POSITION: absolute; TOP: 8px" runat="server"></CR:CrystalReportViewer>
</form>
</body>
</HTML>
File report.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls; namespace begin_report2
{
public class report : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
private void Page_Load(object sender, System.EventArgs e)
{
string country = Request.Params["Country"]; customers1 CustomersReport = new customers1();
CrystalDecisions.Shared.TableLogOnInfo myLogin;
foreach(CrystalDecisions.CrystalReports.Engine.Table myTable in CustomersReport.Database.Tables)
{
myLogin = myTable.LogOnInfo;
myLogin.ConnectionInfo.Password = "";
myLogin.ConnectionInfo.UserID = "sa";
myTable.ApplyLogOnInfo(myLogin);
} CrystalReportViewer1.ReportSource = CustomersReport; CrystalDecisions.Shared.ParameterField pfItemId = new CrystalDecisions.Shared.ParameterField();
pfItemId.ParameterFieldName = "Country"; CrystalDecisions.Shared.ParameterDiscreteValue dcItemId = new CrystalDecisions.Shared.ParameterDiscreteValue();
dcItemId.Value = country; pfItemId.CurrentValues.Add(dcItemId); CrystalDecisions.Shared.ParameterFields paramFields = new CrystalDecisions.Shared.ParameterFields();
paramFields.Add(pfItemId); CrystalReportViewer1.ParameterFieldInfo = paramFields;
}
Thank
Nisarat