Click here to Skip to main content
15,884,866 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i created a user control contain aspxgridview and page contain this user control and button when i click on the button in the page i pass values to methods in my user control
this code in the page pass values to method in user control
C#
protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            DisplayAttachmentControl d = new DisplayAttachmentControl();
            d.DisplayData(5, null);
        }


this is the method in my user control
C#
public void DisplayData(int? documentId, int? ticketId)
        {
            Attachments attachment = new Attachments();
            dt = attachment.GetAttachmentByDocumentIDorTicketID(documentId, null);

            ASPxGridView1.DataSource = dt;
            ASPxGridView1.DataBind();
        }


the problem is when i pass datatable to aspxgridview1 this error appear
Quote:
System.NullReferenceException: Object reference not set to an instance of an object.


because aspxgridview1 is null how can i fix that ?
Posted
Comments
tranesyasd 26-Aug-15 4:06am    
can any one answer me please ?

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