User-330142929 posted
Hi Mukesh1,
When I binding the gridview it's working fine, but when I try to add another row to grid by clicking
a button it shows null reference error on postback.
According to your description, when the page is resubmitted to the server, if you do not perform a rebind function in page_load, it is flushed as soon as it refreshes, or you do not put the Gridview binding event in the If(!ispostback), the row_created
event parameter will get a null reference.
So I suggest you bind the data in page_load, just like this:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GridView1.DataSource = GetDataTable();
this.GridView1.DataBind();
}
}
If the solution could not solve your problem, please feel free to let me know.
Best Regards,
Abraham