protected void on_row(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "View")
        {
            int        rowindex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
            LinkButton lbtn     = (LinkButton)grdPatients.Rows[rowindex].FindControl("btnView");
            Toolkit1.RegisterPostBackControl(lbtn);
            string value = ((Label)grdPatients.Rows[rowindex].FindControl("lblID")).Text;
            Session["PatientID"] = value;
            Session["Operation"] = "Edit";
            Server.Transfer("~/Screens/PatientMaster.aspx");
        }
        if (e.CommandName == "Visit")
        {
            int        rowindex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
            LinkButton lbtn     = (LinkButton)grdPatients.Rows[rowindex].FindControl("btnVisit");
            Toolkit1.RegisterPostBackControl(lbtn);
            string value = ((Label)grdPatients.Rows[rowindex].FindControl("lblID")).Text;
            Session["PatientID"] = value;
            master = new DietMasterManager();

            Int32 i = master.UpdateClientData(Convert.ToInt16(Session["PatientID"].ToString()));
            if (i == 1)
            {
                Tell.text("Marked as visit successfully!!", this);
            }
            else if (i == -1)
            {
                Tell.text("Visit already marked today!!", this);
            }
            else
            {
                Tell.text("Visit not marked !!", this);
            }

            dtSearchMaster         = master.SearchPatients("", "ALL", Convert.ToString(Session["UserCode"]));
            grdPatients.DataSource = dtSearchMaster;
            grdPatients.DataBind();
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     //Session["UserCode"] = "SUPERADMIN";
     Toolkit1.RegisterPostBackControl(btnNew);
     if (!IsPostBack)
     {
         //BusinessHelper<IDietMaster>.Use(DietMasterManager =>
         //{
         //    dtSearchMaster = DietMasterManager.SearchPatients("", "ALL");
         //});
         ViewState["Alphabet"] = "A";
         this.GenerateAlphabets();
         dtSearchMaster         = master.SearchPatients("A", "NAME", Convert.ToString(Session["UserCode"]));
         grdPatients.DataSource = dtSearchMaster;
         grdPatients.DataBind();
         Session["PatientID"] = 0;
         Session["Operation"] = "";
     }
 }