First add a gridview in your page and go to the source view of your page and find the gridview inside which you want to add the textbox and you can insert a code as below (the one in bold blue color) and it will add the textbox into the gridview when it is bound to the database object.
-------------------------------------------------------------
Just below it is the code with which you can access these individual textbox in the different rows.
-------------------------------------------------------------------------------------
for (int j = 0; j < GridView1.Rows.Count; j++)
{
Control cnt;
cnt = GridView1.Rows[j].Cells[3].Controls[1];
cnt = GridView1.Rows[j].FindControl("txtValue");
TextBox txtBx = (TextBox)cnt;
//write your code here to maniupulate the content of textbox
}
Most of the posts in this blog are the information I collected over the internet. I have looked for them for my own purpose and have posted here so that others might benefit as well
Wednesday, May 21, 2008
Monday, May 12, 2008
How to pass login parameter (username, password) of database to crystal report from code
using CrystalDecisions.Reporting;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
private void displayReport()
{
try
{
CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
ConnectionInfo connInfo = new ConnectionInfo();
TableLogOnInfo tblLogInfo = new TableLogOnInfo();
TableLogOnInfos tblLogInfos = new TableLogOnInfos();
connInfo.UserID = "usrName";
connInfo.Password = "passwd";
connInfo.ServerName = "database";
tblLogInfo.ConnectionInfo = connInfo;
tblLogInfos.Add(tblLogInfo);
CrystalReportViewer1.LogOnInfo = tblLogInfos;
CrystalReportViewer1.EnableParameterPrompt = false;
CrystalReportSource1.ReportDocument.FileName=Server.MapPath ("Reports\\crystNewMain.rpt");
}
Catch
{
}
}
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
private void displayReport()
{
try
{
CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
ConnectionInfo connInfo = new ConnectionInfo();
TableLogOnInfo tblLogInfo = new TableLogOnInfo();
TableLogOnInfos tblLogInfos = new TableLogOnInfos();
connInfo.UserID = "usrName";
connInfo.Password = "passwd";
connInfo.ServerName = "database";
tblLogInfo.ConnectionInfo = connInfo;
tblLogInfos.Add(tblLogInfo);
CrystalReportViewer1.LogOnInfo = tblLogInfos;
CrystalReportViewer1.EnableParameterPrompt = false;
CrystalReportSource1.ReportDocument.FileName=Server.MapPath ("Reports\\crystNewMain.rpt");
}
Catch
{
}
}
Saturday, May 10, 2008
How to pass parameter to crystal report from ASP.NET
Suppose there is a crystal report which expects parameter id and section. Here’s the code that shows how to pass the parameter through ASP.net
Before this please do not forget to use following namespaces
using CrystalDecisions.Reporting;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
private void displayReport(number id,string section)
{
try
{
CrystalReportViewer1.EnableParameterPrompt = false;
ParameterFields pFields = new ParameterFields();
ParameterField pField1 = new ParameterField();
ParameterField pField2 = new ParameterField();
ParameterDiscreteValue pDisValue1 = new ParameterDiscreteValue();
ParameterDiscreteValue pDisValue2 = new ParameterDiscreteValue();
pField1.Name = "id";
pField2.Name = "section";
pDisValue1.Value = id;
pField1.CurrentValues.Add(pDisValue1);
pFields.Add(pField1);
pDisValue2.Value = section;
pField2.CurrentValues.Add(pDisValue2);
pFields.Add(pField2);
CrystalReportViewer1.ParameterFieldInfo = pFields;
}
Catch
{
}
}
Before this please do not forget to use following namespaces
using CrystalDecisions.Reporting;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
private void displayReport(number id,string section)
{
try
{
CrystalReportViewer1.EnableParameterPrompt = false;
ParameterFields pFields = new ParameterFields();
ParameterField pField1 = new ParameterField();
ParameterField pField2 = new ParameterField();
ParameterDiscreteValue pDisValue1 = new ParameterDiscreteValue();
ParameterDiscreteValue pDisValue2 = new ParameterDiscreteValue();
pField1.Name = "id";
pField2.Name = "section";
pDisValue1.Value = id;
pField1.CurrentValues.Add(pDisValue1);
pFields.Add(pField1);
pDisValue2.Value = section;
pField2.CurrentValues.Add(pDisValue2);
pFields.Add(pField2);
CrystalReportViewer1.ParameterFieldInfo = pFields;
}
Catch
{
}
}
Subscribe to:
Posts (Atom)