Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi please help me about this problem:
how i can pass value from C# web application into stimulsoft TextBox:
my code :
C#
protected void Page_Load(object sender, EventArgs e)
    {
        this.txt_egample.Text = Decrypt(Request.QueryString["eg"]);
        this.txt_sh_p.Text = Decrypt(Request.QueryString["sh_p"]);
        this.txt_radif_mahkom.Text = Decrypt(Request.QueryString["radif_mah"]);
        this.txt_radif_dad.Text = Decrypt(Request.QueryString["radif_dad"]);
        StiWebViewer1.Visible = true;
        string ConnectionString = ConfigurationManager.ConnectionStrings["Database_ejraConnectionString"].ConnectionString;
        string serverlocation = HttpContext.Current.Server.MapPath(string.Empty);
        StiReport myreport = new StiReport();
        StiText txt = new StiText();
        myreport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Coneection", ConnectionString));
        
        txt = (StiText)myreport.GetComponentByName("Text5");
        txt.Text = txt_egample.Text;
        myreport.Load(serverlocation + "\\rep\\Report2.mrt");
        myreport.Dictionary.Variables["sh_par"].Value = txt_sh_p.Text;
        myreport.Dictionary.Variables["rad"].Value = txt_radif_mahkom.Text;
        myreport.Dictionary.Variables["rad_dad"].Value = txt_radif_dad.Text;
        
        StiWebViewer1.Report = myreport;
    }


C#
i try above code but this error display on this line:
Object reference not set to an instance of an object.
txt.Text = txt_egample.Text; 


thanks

What I have tried:

i try above code but this error display on this line:
Object reference not set to an instance of an object.
txt.Text = txt_egample.Text;
Posted
Updated 1-Apr-16 3:07am
v8
Comments
Jochen Arndt 1-Apr-16 8:40am    
There is no line in your posted code snippet that contains the assignment from the error message.
rezaeti 1-Apr-16 8:42am    
txt.Text = txt_date.Text;
rezaeti 1-Apr-16 8:42am    
thanks for reply
can you help me?
rezaeti 1-Apr-16 8:43am    
excuse me
this line is correct
txt.Text = txt_egample.Text;
Karthik_Mahalingam 1-Apr-16 9:51am    
this function is returning null value
myreport.GetComponentByName("Text5");
make sure that "Text5" is available on the report

1 solution

The error message indicates that either txt or txt_egample is NULL.

I guess it is txt when there is no component named "Text5" here:
C#
txt = (StiText)myreport.GetComponentByName("Text5")


You are also assigning to txt after you have allocated an StiText instance here so that this instance is never used:
C#
StiText txt = new StiText();


I don't know StimulSoft but it seems you can just use
C#
StiText txt = (StiText)myreport.GetComponentByName("Text5")

and omit the allocation. But you should still check if txt is valid (not empty).

[EDIT]
Sorry, I forget that you want to set the text.
There is a SetText function:
C#
StiText txt = (StiText)myreport.GetComponentByName("Text5");
txt.SetText(txt_egample.Text);

[/EDIT]
 
Share this answer
 
v2
Comments
rezaeti 1-Apr-16 9:11am    
thanks for reply i try it.
but my problem is remaind yet.
Jochen Arndt 1-Apr-16 9:15am    
See my updated answer to set the text (hope it works that way).

But you must ensure that the component is present.
Only you can check (and should know) which components are present in the report.
rezaeti 1-Apr-16 9:12am    
txt_egample is not null
but txt.Text is null
i dont know what is wrong in here?
rezaeti 1-Apr-16 9:25am    
thanks Jochen Arndt dont work
the error :
Object reference not set to an instance of an object.
rezaeti 1-Apr-16 9:27am    
i check and sure the txt_egample is exist in my page and Text5 also exist in my report

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900