How to get control in static webmethod.
it show error object refrence not set instance of object
how can i do this tell me right solution to perform this
OPD is my page name
[WebMethod]
public static string GetCustomersInfoRegiidOpdod(string regids, string opdids)
{
OPD op = new OPD();
op.getCustomerRecords(regids, opdids);
return null;
}
so i make i instance of my page to call a function getCustomerRecords()
protected void getCustomerRecords(string regids, string opdids)
{
string regdno = regids.ToString();
setcontrol();
DataTable RegDetails = SqlObject.get_info_Patient(regids, opdids);
//AAA---------------------
global.regid = regids;
txtregistrationno.Text = regids;
txtname.Text = RegDetails.Rows[0]["patientname"].ToString();
//DateTime date = DateTime.ParseExact(RegDetails.Rows[0]["date"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
txtdate.Text = Convert.ToDateTime(RegDetails.Rows[0]["date"]).ToString("dd/MM/yyyy");
if (RegDetails.Rows[0]["age"].ToString() != "0")
{
txtage.Text = RegDetails.Rows[0]["age"].ToString();
}
if (RegDetails.Rows[0]["contactno"].ToString() != " ")
{
txtnumber.Text = RegDetails.Rows[0]["contactno"].ToString();
}
txtopdnum.Text = opdids;
drop_gender.SelectedValue = RegDetails.Rows[0]["sex"].ToString();
ddlmarried_status.SelectedValue = RegDetails.Rows[0]["mstatus"].ToString();
ddl_occupation.SelectedValue = RegDetails.Rows[0]["occupation"].ToString();
if (RegDetails.Rows[0]["address"].ToString() != " ")
{
txtaddress.Text = RegDetails.Rows[0]["address"].ToString();
}
//global records all data regarding patient
string regid = regids;
string opdid = opdids;
DataTable dt = SqlObject.get_All_record_regarding_patient(regid, opdid);
//presentingComplaints
DataTable dt1 = new DataTable();
DataView dv = new DataView(dt);
dv.RowFilter = "vtype='pc'";
dt1 = dv.ToTable();
ViewState["presentingcomplaints"] = dt1;
var count = dt1.Rows.Count;
if (count == 0)
{
}
else
{
DataRow dr = (DataRow)dt1.Rows[dt1.Rows.Count - 1];
var d = dr["id"];
ViewState["Number"] = 0;
GridView1.DataSource = dt1;
GridView1.DataBind();
}
}