when textbox getting the data through datatable object in static method at that time it shows the null value (i.e. showing error : object reference not set to an instance of the object). But when I am doing the debug mode at that time it shows the data in the datatable, so from that I am confusing that how in textbox it getting the null value.
Here is my code
[WebMethod]
public static void GetCnorGSTNo(string Param1)
{
Page page = (Page)HttpContext.Current.Handler;
TextBox cnorGST = (TextBox)page.FindControl("txtbx_cnortin");
DataAccess clsObjDataAccess = new DataAccess();
string qrySelCnorGtinNo = "select TinNo1 from CnorMaster where CnorName = '" + Param1 + "'";
DataTable dtqrySelCnorGtinNo = new DataTable();
dtqrySelCnorGtinNo = clsObjDataAccess.GetDataTable(qrySelCnorGtinNo);
if (dtqrySelCnorGtinNo.Rows.Count > 0)
{
cnorGST.Text = dtqrySelCnorGtinNo.Rows[0]["TinNo1"].ToString();
}
}
When I am doing in debug mode
"dtqrySelCnorGtinNo.Rows[0]["TinNo1"].ToString();"
this line shows the data
but when this data is giving to the textbox i.e. cnorGST.Text
at that time it showing an error i.e. object reference not set to an instance of the object.
Please help me to solve this issues.
Thank You.