Solved

Error using ViewState["CurrentTable"] ASP.NET

Posted on 2011-03-06
6
1,165 Views
Last Modified: 2012-05-11
I am having issues on adding two data tables (one for each Gridview) and adding the rows dynamically

it seems that the Session  ViewState is conflicting,, can you please tell me how can I get to do this

I get Column 'RowNumber' does not belong to table Table1.

drCurrentRow["RowNumber"] = i + 1;
Line 218:
Line 219:                    drCurrentRow["NT1"] = box1.Text;
cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Specialized;
using System.Text;
using System.Data.SqlClient;

public partial class GridViewWithTextBoxes : System.Web.UI.Page
{

    private void SetInitialRow()
    {
        DataTable dt = new DataTable();
        DataRow dr = null;

        dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
        //dt.Columns.Add(new DataColumn("Date", typeof(string)));

        dt.Columns.Add(new DataColumn("NT1", typeof(string)));
        //dt.Columns.Add(new DataColumn("NT1_Status", typeof(string)));

        dt.Columns.Add(new DataColumn("NT1_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("NT2", typeof(string)));
        dt.Columns.Add(new DataColumn("NT2_Status", typeof(string)));
        //   dt.Columns.Add(new DataColumn("NT2_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("NT3", typeof(string)));
        dt.Columns.Add(new DataColumn("NT3_Status", typeof(string)));


        // dt.Columns.Add(new DataColumn("NT3_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("ICU", typeof(string)));
        dt.Columns.Add(new DataColumn("ICU_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("SDU", typeof(string)));
        dt.Columns.Add(new DataColumn("SDU_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("Tele3rd1", typeof(string)));
        dt.Columns.Add(new DataColumn("Tele3rd1_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("Tele3rd2", typeof(string)));
        dt.Columns.Add(new DataColumn("Tele3rd2_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("Tele4th1", typeof(string)));
        dt.Columns.Add(new DataColumn("Tele4th1_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("Tele4th2", typeof(string)));
        dt.Columns.Add(new DataColumn("Tele4th2_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("Pedi3rd", typeof(string)));
        dt.Columns.Add(new DataColumn("Pedi3rd_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("Pedi4th", typeof(string)));
        dt.Columns.Add(new DataColumn("Pedi4th_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("PICU_SD", typeof(string)));
        dt.Columns.Add(new DataColumn("PICU_SD_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("ER", typeof(string)));
        dt.Columns.Add(new DataColumn("ER_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("MICU", typeof(string)));
        dt.Columns.Add(new DataColumn("MICU_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("CPV", typeof(string)));
        dt.Columns.Add(new DataColumn("CPV_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("CVOR", typeof(string)));
        dt.Columns.Add(new DataColumn("CVOR_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("CLOF", typeof(string)));
        dt.Columns.Add(new DataColumn("CLOF_Status", typeof(string)));


        dt.Columns.Add(new DataColumn("CVOR_HOLDING", typeof(string)));
        dt.Columns.Add(new DataColumn("CVOR_HOLDING_Status", typeof(string)));



        dr = dt.NewRow();
        dr["RowNumber"] = 1;
        // dr["Date"] = string.Empty;
        dr["NT1"] = string.Empty;
        dr["NT2"] = string.Empty;
        dr["NT3"] = string.Empty;
        dr["ICU"] = string.Empty;
        dr["SDU"] = string.Empty;
        dr["Tele3rd1"] = string.Empty;
        dr["Tele3rd2"] = string.Empty;
        dr["Tele4th1"] = string.Empty;
        dr["Tele4th2"] = string.Empty;
        dr["Pedi3rd"] = string.Empty;
        dr["Pedi4th"] = string.Empty;
        dr["PICU_SD"] = string.Empty;
        dr["ER"] = string.Empty;
        dr["MICU"] = string.Empty;
        dr["CPV"] = string.Empty;
        dr["CVOR"] = string.Empty;
        dr["CLOF"] = string.Empty;
        dr["CVOR_HOLDING"] = string.Empty;

        dt.Rows.Add(dr);
        //dr = dt.NewRow();

        //Store the DataTable in ViewState
        ViewState["CurrentTable"] = dt;

        Gridview1.DataSource = dt;
        Gridview1.DataBind();

    }


    private void AddNewRowToGrid()
    {
        int rowIndex = 0;

        if (ViewState["CurrentTable"] != null)
        {
            DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
            DataRow drCurrentRow = null;
            if (dtCurrentTable.Rows.Count > 0)
            {
                for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                {
                    //extract the TextBox  and DropDown values



                    TextBox box1 = (TextBox)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Bed1");
                    DropDownList box2 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment1");

                    TextBox box3 = (TextBox)Gridview1.Rows[rowIndex].Cells[2].FindControl("txt_Bed2");
                    DropDownList box4 = (DropDownList)Gridview1.Rows[rowIndex].Cells[2].FindControl("txt_Comment2");

                    TextBox box5 = (TextBox)Gridview1.Rows[rowIndex].Cells[3].FindControl("txt_Bed3");
                    DropDownList box6 = (DropDownList)Gridview1.Rows[rowIndex].Cells[3].FindControl("txt_Comment3");

                    TextBox box7 = (TextBox)Gridview1.Rows[rowIndex].Cells[4].FindControl("txt_Bed4");
                    DropDownList box8 = (DropDownList)Gridview1.Rows[rowIndex].Cells[4].FindControl("txt_Comment4");

                    TextBox box9 = (TextBox)Gridview1.Rows[rowIndex].Cells[5].FindControl("txt_Bed5");
                    DropDownList box10 = (DropDownList)Gridview1.Rows[rowIndex].Cells[5].FindControl("txt_Comment5");

                    TextBox box11 = (TextBox)Gridview1.Rows[rowIndex].Cells[6].FindControl("txt_Bed6");
                    DropDownList box12 = (DropDownList)Gridview1.Rows[rowIndex].Cells[6].FindControl("txt_Comment6");


                    TextBox box13 = (TextBox)Gridview1.Rows[rowIndex].Cells[7].FindControl("txt_Bed7");
                    DropDownList box14 = (DropDownList)Gridview1.Rows[rowIndex].Cells[7].FindControl("txt_Comment7");

                    TextBox box15 = (TextBox)Gridview1.Rows[rowIndex].Cells[8].FindControl("txt_Bed8");
                    DropDownList box16 = (DropDownList)Gridview1.Rows[rowIndex].Cells[8].FindControl("txt_Comment8");

                    TextBox box17 = (TextBox)Gridview1.Rows[rowIndex].Cells[9].FindControl("txt_Bed9");
                    DropDownList box18 = (DropDownList)Gridview1.Rows[rowIndex].Cells[9].FindControl("txt_Comment9");

                    TextBox box19 = (TextBox)Gridview1.Rows[rowIndex].Cells[10].FindControl("txt_Bed10");
                    DropDownList box20 = (DropDownList)Gridview1.Rows[rowIndex].Cells[10].FindControl("txt_Comment10");


                    TextBox box21 = (TextBox)Gridview1.Rows[rowIndex].Cells[11].FindControl("txt_Bed11");
                    DropDownList box22 = (DropDownList)Gridview1.Rows[rowIndex].Cells[11].FindControl("txt_Comment11");

                    TextBox box23 = (TextBox)Gridview1.Rows[rowIndex].Cells[12].FindControl("txt_Bed12");
                    DropDownList box24 = (DropDownList)Gridview1.Rows[rowIndex].Cells[12].FindControl("txt_Comment12");

                    TextBox box25 = (TextBox)Gridview1.Rows[rowIndex].Cells[13].FindControl("txt_Bed13");
                    DropDownList box26 = (DropDownList)Gridview1.Rows[rowIndex].Cells[13].FindControl("txt_Comment13");

                    TextBox box27 = (TextBox)Gridview1.Rows[rowIndex].Cells[14].FindControl("txt_Bed14");
                    DropDownList box28 = (DropDownList)Gridview1.Rows[rowIndex].Cells[14].FindControl("txt_Comment14");

                    TextBox box29 = (TextBox)Gridview1.Rows[rowIndex].Cells[15].FindControl("txt_Bed15");
                    DropDownList box30 = (DropDownList)Gridview1.Rows[rowIndex].Cells[15].FindControl("txt_Comment15");

                    TextBox box31 = (TextBox)Gridview1.Rows[rowIndex].Cells[16].FindControl("txt_Bed16");
                    DropDownList box32 = (DropDownList)Gridview1.Rows[rowIndex].Cells[16].FindControl("txt_Comment16");

                    TextBox box33 = (TextBox)Gridview1.Rows[rowIndex].Cells[17].FindControl("txt_Bed17");
                    DropDownList box34 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment17");


                    TextBox box35 = (TextBox)Gridview1.Rows[rowIndex].Cells[18].FindControl("txt_Bed18");
                    DropDownList box36 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment18");

                    drCurrentRow = dtCurrentTable.NewRow();


                    drCurrentRow["RowNumber"] = i + 1;

                    drCurrentRow["NT1"] = box1.Text;
                    drCurrentRow["NT1_Status"] = box2.SelectedValue;


                    drCurrentRow["NT2"] = box3.Text;
                    drCurrentRow["NT2_Status"] = box4.SelectedValue;


                    drCurrentRow["NT3"] = box5.Text;
                    drCurrentRow["NT3_Status"] = box6.SelectedValue;


                    drCurrentRow["ICU"] = box7.Text;
                    drCurrentRow["ICU_Status"] = box8.SelectedValue;

                    // drCurrentRow["SDU_Census"] = box1.Text;
                    drCurrentRow["SDU"] = box9.Text;
                    drCurrentRow["SDU_Status"] = box10.SelectedValue;

                    //drCurrentRow["Tele3rd1_Census"] = box1.Text;
                    drCurrentRow["Tele3rd1"] = box11.Text;
                    drCurrentRow["Tele3rd1_Status"] = box12.SelectedValue;

                    //drCurrentRow["Tele3rd2_Census"] = box1.Text;
                    drCurrentRow["Tele3rd2"] = box13.Text;
                    drCurrentRow["Tele3rd2_Status"] = box14.SelectedValue;

                    //drCurrentRow["Tele4th1_Census"] = box1.Text;
                    drCurrentRow["Tele4th1"] = box15.Text;
                    drCurrentRow["Tele4th1_Status"] = box16.SelectedValue;

                    //drCurrentRow["Tele4th2_Census"] = box1.Text;
                    drCurrentRow["Tele4th2"] = box17.Text;
                    drCurrentRow["Tele4th2_Status"] = box18.SelectedValue;

                    //drCurrentRow["Pedi3rd_Census"] = box1.Text;
                    drCurrentRow["Pedi3rd"] = box19.Text;
                    drCurrentRow["Pedi3rd_Status"] = box20.SelectedValue;

                    //drCurrentRow["Pedi4th_Census"] = box1.Text;
                    drCurrentRow["Pedi4th"] = box21.Text;
                    drCurrentRow["Pedi4th_Status"] = box22.SelectedValue;

                    // drCurrentRow["PICU_SD_Census"] = box1.Text;
                    drCurrentRow["PICU_SD"] = box23.Text;
                    drCurrentRow["PICU_SD_Status"] = box24.SelectedValue;

                    //drCurrentRow["ER_Census"] = box1.Text;
                    drCurrentRow["ER"] = box25.Text;
                    drCurrentRow["ER_Status"] = box26.SelectedValue;

                    // drCurrentRow["MICU_Census"] = box1.Text;
                    drCurrentRow["MICU"] = box27.Text;
                    drCurrentRow["MICU_Status"] = box28.SelectedValue;

                    //drCurrentRow["CPV_Census"] = box1.Text;
                    drCurrentRow["CPV"] = box29.Text;
                    drCurrentRow["CPV_Status"] = box30.SelectedValue;

                    //drCurrentRow["CVOR_Census"] = box1.Text;
                    drCurrentRow["CVOR"] = box31.Text;
                    drCurrentRow["CVOR_Status"] = box32.SelectedValue;

                    drCurrentRow["CLOF"] = box33.Text;
                    drCurrentRow["CLOF_Status"] = box34.SelectedValue;


                    //drCurrentRow["CVOR_HOLDING_Census"] = box1.Text;
                    drCurrentRow["CVOR_HOLDING"] = box35.Text;
                    drCurrentRow["CVOR_HOLDING_Status"] = box36.SelectedValue;

                    rowIndex++;
                }


                dtCurrentTable.Rows.Add(drCurrentRow);
                ViewState["CurrentTable"] = dtCurrentTable;

                Gridview1.DataSource = dtCurrentTable;
                Gridview1.DataBind();
            }
        }
        else
        {
            Response.Write("ViewState is null");
        }

        //Set Previous Data on Postbacks
        SetPreviousData();
    }


    private void SetPreviousData()
    {
        int rowIndex = 0;
        if (ViewState["CurrentTable"] != null)
        {
            DataTable dt = (DataTable)ViewState["CurrentTable"];
            if (dt.Rows.Count > 0)
            {
                for (int i = 1; i < dt.Rows.Count; i++)
                {

                    TextBox box1 = (TextBox)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Bed1");
                    DropDownList box2 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment1");

                    TextBox box3 = (TextBox)Gridview1.Rows[rowIndex].Cells[2].FindControl("txt_Bed2");
                    DropDownList box4 = (DropDownList)Gridview1.Rows[rowIndex].Cells[2].FindControl("txt_Comment2");

                    TextBox box5 = (TextBox)Gridview1.Rows[rowIndex].Cells[3].FindControl("txt_Bed3");
                    DropDownList box6 = (DropDownList)Gridview1.Rows[rowIndex].Cells[3].FindControl("txt_Comment3");

                    TextBox box7 = (TextBox)Gridview1.Rows[rowIndex].Cells[4].FindControl("txt_Bed4");
                    DropDownList box8 = (DropDownList)Gridview1.Rows[rowIndex].Cells[4].FindControl("txt_Comment4");

                    TextBox box9 = (TextBox)Gridview1.Rows[rowIndex].Cells[5].FindControl("txt_Bed5");
                    DropDownList box10 = (DropDownList)Gridview1.Rows[rowIndex].Cells[5].FindControl("txt_Comment5");

                    TextBox box11 = (TextBox)Gridview1.Rows[rowIndex].Cells[6].FindControl("txt_Bed6");
                    DropDownList box12 = (DropDownList)Gridview1.Rows[rowIndex].Cells[6].FindControl("txt_Comment6");


                    TextBox box13 = (TextBox)Gridview1.Rows[rowIndex].Cells[7].FindControl("txt_Bed7");
                    DropDownList box14 = (DropDownList)Gridview1.Rows[rowIndex].Cells[7].FindControl("txt_Comment7");

                    TextBox box15 = (TextBox)Gridview1.Rows[rowIndex].Cells[8].FindControl("txt_Bed8");
                    DropDownList box16 = (DropDownList)Gridview1.Rows[rowIndex].Cells[8].FindControl("txt_Comment8");

                    TextBox box17 = (TextBox)Gridview1.Rows[rowIndex].Cells[9].FindControl("txt_Bed9");
                    DropDownList box18 = (DropDownList)Gridview1.Rows[rowIndex].Cells[9].FindControl("txt_Comment9");

                    TextBox box19 = (TextBox)Gridview1.Rows[rowIndex].Cells[10].FindControl("txt_Bed10");
                    DropDownList box20 = (DropDownList)Gridview1.Rows[rowIndex].Cells[10].FindControl("txt_Comment10");


                    TextBox box21 = (TextBox)Gridview1.Rows[rowIndex].Cells[11].FindControl("txt_Bed11");
                    DropDownList box22 = (DropDownList)Gridview1.Rows[rowIndex].Cells[11].FindControl("txt_Comment11");

                    TextBox box23 = (TextBox)Gridview1.Rows[rowIndex].Cells[12].FindControl("txt_Bed12");
                    DropDownList box24 = (DropDownList)Gridview1.Rows[rowIndex].Cells[12].FindControl("txt_Comment12");

                    TextBox box25 = (TextBox)Gridview1.Rows[rowIndex].Cells[13].FindControl("txt_Bed13");
                    DropDownList box26 = (DropDownList)Gridview1.Rows[rowIndex].Cells[13].FindControl("txt_Comment13");

                    TextBox box27 = (TextBox)Gridview1.Rows[rowIndex].Cells[14].FindControl("txt_Bed14");
                    DropDownList box28 = (DropDownList)Gridview1.Rows[rowIndex].Cells[14].FindControl("txt_Comment14");

                    TextBox box29 = (TextBox)Gridview1.Rows[rowIndex].Cells[15].FindControl("txt_Bed15");
                    DropDownList box30 = (DropDownList)Gridview1.Rows[rowIndex].Cells[15].FindControl("txt_Comment15");

                    TextBox box31 = (TextBox)Gridview1.Rows[rowIndex].Cells[16].FindControl("txt_Bed16");
                    DropDownList box32 = (DropDownList)Gridview1.Rows[rowIndex].Cells[16].FindControl("txt_Comment16");

                    TextBox box33 = (TextBox)Gridview1.Rows[rowIndex].Cells[17].FindControl("txt_Bed17");
                    DropDownList box34 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment17");


                    TextBox box35 = (TextBox)Gridview1.Rows[rowIndex].Cells[18].FindControl("txt_Bed18");
                    DropDownList box36 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment18");



                    // Assign Values to textboxes


                    box1.Text = dt.Rows[i]["NT1"].ToString();
                    box2.Text = dt.Rows[i]["NT1_Status"].ToString();


                    box3.Text = dt.Rows[i]["NT2"].ToString();
                    box4.Text = dt.Rows[i]["NT2_Status"].ToString();


                    box5.Text = dt.Rows[i]["NT3"].ToString();
                    box6.Text = dt.Rows[i]["NT3_Status"].ToString();


                    box7.Text = dt.Rows[i]["ICU"].ToString();
                    box8.Text = dt.Rows[i]["ICU_Status"].ToString();


                    box9.Text = dt.Rows[i]["SDU"].ToString();
                    box10.Text = dt.Rows[i]["SDU_Status"].ToString();


                    box11.Text = dt.Rows[i]["Tele3rd1"].ToString();
                    box12.Text = dt.Rows[i]["Tele3rd1_Status"].ToString();


                    box13.Text = dt.Rows[i]["Tele3rd2"].ToString();
                    box14.Text = dt.Rows[i]["Tele3rd2_Status"].ToString();


                    box15.Text = dt.Rows[i]["Tele4th1"].ToString();
                    box16.Text = dt.Rows[i]["Tele4th1_Status"].ToString();


                    box17.Text = dt.Rows[i]["Tele4th2"].ToString();
                    box18.Text = dt.Rows[i]["Tele4th2_Status"].ToString();


                    box19.Text = dt.Rows[i]["Pedi3rd"].ToString();
                    box20.Text = dt.Rows[i]["Pedi3rd_Status"].ToString();


                    box21.Text = dt.Rows[i]["Pedi4th"].ToString();
                    box22.Text = dt.Rows[i]["Pedi4th_Status"].ToString();


                    box23.Text = dt.Rows[i]["PICU_SD"].ToString();
                    box24.Text = dt.Rows[i]["PICU_SD_Status"].ToString();


                    box25.Text = dt.Rows[i]["ER"].ToString();
                    box26.Text = dt.Rows[i]["ER_Status"].ToString();


                    box27.Text = dt.Rows[i]["MICU"].ToString();
                    box28.Text = dt.Rows[i]["MICU_Status"].ToString();


                    box29.Text = dt.Rows[i]["CPV"].ToString();
                    box30.Text = dt.Rows[i]["CPV_Status"].ToString();


                    box31.Text = dt.Rows[i]["CVOR"].ToString();
                    box32.Text = dt.Rows[i]["CVOR_Status"].ToString();


                    box33.Text = dt.Rows[i]["CLOF"].ToString();
                    box34.Text = dt.Rows[i]["CLOF_Status"].ToString();


                    box35.Text = dt.Rows[i]["CVOR_HOLDING"].ToString();
                    box36.Text = dt.Rows[i]["CVOR_HOLDING_Status"].ToString();

                    rowIndex++;

                }
            }
            // ViewState["CurrentTable"] = dt;

        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        string authUserName;
        authUserName = User.Identity.Name;

        /*If page is not a Postback */


        dateLabel.Text = DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm");


        if (!Page.IsPostBack)
        {
            SetInitialRow();
            SetInitialRow2();
        }
    }


    protected void ButtonAdd_Click(object sender, EventArgs e)
    {
        AddNewRowToGrid();
    }




    protected void Button1_Click(object sender, EventArgs e)
    {
        int rowIndex = 0;
        StringCollection sc = new StringCollection();
        if (ViewState["CurrentTable"] != null)
        {
            DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
            if (dtCurrentTable.Rows.Count > 0)
            {
                for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                {
                    //extract the TextBox and DropDowns values
                    TextBox box1 = (TextBox)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Bed1");
                    DropDownList box2 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment1");

                    TextBox box3 = (TextBox)Gridview1.Rows[rowIndex].Cells[2].FindControl("txt_Bed2");
                    DropDownList box4 = (DropDownList)Gridview1.Rows[rowIndex].Cells[2].FindControl("txt_Comment2");

                    TextBox box5 = (TextBox)Gridview1.Rows[rowIndex].Cells[3].FindControl("txt_Bed3");
                    DropDownList box6 = (DropDownList)Gridview1.Rows[rowIndex].Cells[3].FindControl("txt_Comment3");

                    TextBox box7 = (TextBox)Gridview1.Rows[rowIndex].Cells[4].FindControl("txt_Bed4");
                    DropDownList box8 = (DropDownList)Gridview1.Rows[rowIndex].Cells[4].FindControl("txt_Comment4");

                    TextBox box9 = (TextBox)Gridview1.Rows[rowIndex].Cells[5].FindControl("txt_Bed5");
                    DropDownList box10 = (DropDownList)Gridview1.Rows[rowIndex].Cells[5].FindControl("txt_Comment5");

                    TextBox box11 = (TextBox)Gridview1.Rows[rowIndex].Cells[6].FindControl("txt_Bed6");
                    DropDownList box12 = (DropDownList)Gridview1.Rows[rowIndex].Cells[6].FindControl("txt_Comment6");


                    TextBox box13 = (TextBox)Gridview1.Rows[rowIndex].Cells[7].FindControl("txt_Bed7");
                    DropDownList box14 = (DropDownList)Gridview1.Rows[rowIndex].Cells[7].FindControl("txt_Comment7");

                    TextBox box15 = (TextBox)Gridview1.Rows[rowIndex].Cells[8].FindControl("txt_Bed8");
                    DropDownList box16 = (DropDownList)Gridview1.Rows[rowIndex].Cells[8].FindControl("txt_Comment8");

                    TextBox box17 = (TextBox)Gridview1.Rows[rowIndex].Cells[9].FindControl("txt_Bed9");
                    DropDownList box18 = (DropDownList)Gridview1.Rows[rowIndex].Cells[9].FindControl("txt_Comment9");

                    TextBox box19 = (TextBox)Gridview1.Rows[rowIndex].Cells[10].FindControl("txt_Bed10");
                    DropDownList box20 = (DropDownList)Gridview1.Rows[rowIndex].Cells[10].FindControl("txt_Comment10");


                    TextBox box21 = (TextBox)Gridview1.Rows[rowIndex].Cells[11].FindControl("txt_Bed11");
                    DropDownList box22 = (DropDownList)Gridview1.Rows[rowIndex].Cells[11].FindControl("txt_Comment11");

                    TextBox box23 = (TextBox)Gridview1.Rows[rowIndex].Cells[12].FindControl("txt_Bed12");
                    DropDownList box24 = (DropDownList)Gridview1.Rows[rowIndex].Cells[12].FindControl("txt_Comment12");

                    TextBox box25 = (TextBox)Gridview1.Rows[rowIndex].Cells[13].FindControl("txt_Bed13");
                    DropDownList box26 = (DropDownList)Gridview1.Rows[rowIndex].Cells[13].FindControl("txt_Comment13");

                    TextBox box27 = (TextBox)Gridview1.Rows[rowIndex].Cells[14].FindControl("txt_Bed14");
                    DropDownList box28 = (DropDownList)Gridview1.Rows[rowIndex].Cells[14].FindControl("txt_Comment14");

                    TextBox box29 = (TextBox)Gridview1.Rows[rowIndex].Cells[15].FindControl("txt_Bed15");
                    DropDownList box30 = (DropDownList)Gridview1.Rows[rowIndex].Cells[15].FindControl("txt_Comment15");

                    TextBox box31 = (TextBox)Gridview1.Rows[rowIndex].Cells[16].FindControl("txt_Bed16");
                    DropDownList box32 = (DropDownList)Gridview1.Rows[rowIndex].Cells[16].FindControl("txt_Comment16");

                    TextBox box33 = (TextBox)Gridview1.Rows[rowIndex].Cells[17].FindControl("txt_Bed17");
                    DropDownList box34 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment17");


                    TextBox box35 = (TextBox)Gridview1.Rows[rowIndex].Cells[18].FindControl("txt_Bed18");
                    DropDownList box36 = (DropDownList)Gridview1.Rows[rowIndex].Cells[1].FindControl("txt_Comment18");

                    DateTime datevar = DateTime.Parse(dateLabel.Text.ToString());
                    String dateLabelFx = DateTime.Now.ToString("dd MMMM yyyy HH:mm");

                    // Noth Tower Header Census


                    TextBox NT1Census = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census1");
                    TextBox NT2Census = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census2");
                    TextBox NT3Census = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census3");
                    TextBox ICUCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census4");
                    TextBox SDUCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census5");
                    TextBox Tele3rd1Census = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census6");
                    TextBox Tele3rd2Census = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census7");
                    TextBox Tele4th1Census = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census8");
                    TextBox Tele4th2Census = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census9");
                    TextBox Pedi3rdCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census10");
                    TextBox Pedi4thCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census11");
                    TextBox PICUCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census12");
                    TextBox MICUCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census13");
                    TextBox ERCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census14");
                    TextBox CPUCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census15");
                    TextBox CVORCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census16");
                    TextBox CLOFCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census17");
                    TextBox CVORHCensus = (TextBox)Gridview1.HeaderRow.FindControl("txt_Census18");


                    //General Census Variables 
                    string bh_Census = txtCensusBehavioral.Text;
                    string wmCensus = txtCensusWomens.Text;
                    string rh_Census = txtCensusREHAB.Text;

                    //get the values from the TextBoxes
                    //then add it to the collections with a comma "," as the delimited values
                    sc.Add(dateLabelFx + "," + bh_Census + "," + wmCensus + "," + rh_Census + "," + NT1Census.Text + "," + NT2Census.Text + "," + NT3Census.Text + "," + ICUCensus.Text + "," + SDUCensus.Text + "," + Tele3rd1Census.Text + "," + Tele3rd2Census.Text + "," + Tele4th1Census.Text + "," + Tele4th2Census.Text + "," + Pedi3rdCensus.Text + "," + Pedi4thCensus.Text + "," + PICUCensus.Text + "," + MICUCensus.Text + "," + ERCensus.Text + "," + CPUCensus.Text + "," + CVORCensus.Text + "," + CLOFCensus.Text + "," + CVORHCensus.Text + "," + box1.Text + "," + box2.Text + "," + box3.Text + "," + box4.Text + "," + box5.Text + "," + box6.Text + "," + box7.Text + "," + box8.Text + "," + box9.Text + "," + box10.Text + "," + box11.Text + "," + box12.Text + "," + box13.Text + "," + box14.Text + "," + box15.Text + "," + box16.Text + "," + box17.Text + "," + box18.Text + "," + box19.Text + "," + box20.Text + "," + box21.Text + "," + box22.Text + "," + box23.Text + "," + box24.Text + "," + box25.Text + "," + box26.Text + "," + box27.Text + "," + box28.Text + "," + box29.Text + "," + box30.Text + "," + box31.Text + "," + box32.Text + "," + box33.Text + "," + box34.Text + "," + box35.Text + "," + box36.Text + ",");
                    rowIndex++;
                }
                //Call the method for executing inserts from main grid
                InsertRecords(sc);


            }
        }
    }
    //A method that returns a string which calls the connection string from the web.config
    private string GetConnectionString()
    {
        //"DBConnection" is the name of the Connection String
        //that was set up from the web.config file
        return System.Configuration.ConfigurationManager.ConnectionStrings["appdevConnectionString2"].ConnectionString;
    }
    //A method that Inserts the records to the database
    private void InsertRecords(StringCollection sc)
    {

        SqlConnection conn = new SqlConnection(GetConnectionString());
        StringBuilder sb = new StringBuilder(string.Empty);


        string[] splitItems = null;


        foreach (string item in sc)
        {

            const string sqlStatement = "INSERT INTO tb_Bed_Control (Date,Behavioral_Census,Womens_Census,Rehab_Census,NT1_Census,NT2_Census,NT3_Census,ICU_Census,SDU_Census,Tele3rd1_Census,Tele3rd2_Census,Tele4th1_Census,Tele4th2_Census,Pedi3rd_Census,Pedi4th_Census,PICU_SD_Census,ER_Census,MICU_Census,CPV_Census,CVOR_Census,CLOF_Census,CVOR_HOLDING_Census,NT1,NT1_Status,NT2,NT2_Status,NT3,NT3_Status,ICU,ICU_Status,SDU,SDU_Status,Tele3rd1,Tele3rd1_Status,Tele3rd2,Tele3rd2_Status,Tele4th1,Tele4th1_Status,Tele4th2,Tele4th2_Status,Pedi3rd,Pedi3rd_Status,Pedi4th,Pedi4th_Status,PICU_SD,PICU_SD_Status,ER,ER_Status,MICU,MICU_Status,CPV,CPV_Status,CVOR,CVOR_Status,CLOF,CLOF_Status,CVOR_HOLDING,CVOR_HOLDING_Status) VALUES";


            //  string sqlStatement2 = "INSERT INTO SampleTable (Behavioral_Census,Womens_Census,Rehab_Census) values('" + txtCensusBehavioral + "','" + txtCensusWomens + "', '" + txtCensusREHAB + "')";


            if (item.Contains(","))
            {
                splitItems = item.Split(",".ToCharArray());

                sb.AppendFormat("{0}('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}','{38}','{39}','{40}','{41}','{42}','{43}','{44}','{45}','{46}','{47}','{48}','{49}','{50}','{51}','{52}','{53}','{54}','{55}','{56}','{57}','{58}'); ", sqlStatement, splitItems[0], splitItems[1], splitItems[2], splitItems[3], splitItems[4], splitItems[5], splitItems[6], splitItems[7], splitItems[8], splitItems[9], splitItems[10], splitItems[11], splitItems[12], splitItems[13], splitItems[14], splitItems[15], splitItems[16], splitItems[17], splitItems[18], splitItems[19], splitItems[20], splitItems[21], splitItems[22], splitItems[23], splitItems[24], splitItems[25], splitItems[26], splitItems[27], splitItems[28], splitItems[29], splitItems[30], splitItems[31], splitItems[32], splitItems[33], splitItems[34], splitItems[35], splitItems[36], splitItems[37], splitItems[38], splitItems[39], splitItems[40], splitItems[41], splitItems[42], splitItems[43], splitItems[44], splitItems[45], splitItems[46], splitItems[47], splitItems[48], splitItems[49], splitItems[50], splitItems[51], splitItems[52], splitItems[53], splitItems[54], splitItems[55], splitItems[56], splitItems[57]);

            }



        }


        try
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand(sb.ToString(), conn);


            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();

            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Available Beds Succesfully Updated');", true);

        }
        catch (System.Data.SqlClient.SqlException ex)
        {
            string msg = "Insert Error:";
            msg += ex.Message;
            throw new Exception(msg);

        }
        finally
        {
            conn.Close();
        }
    }
    // Hide the Remove Button at the last row of the GridView
    protected void Gridview1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataTable dt = (DataTable)ViewState["CurrentTable"];
            LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1");
            if (lb != null)
            {
                if (dt.Rows.Count > 1)
                {
                    if (e.Row.RowIndex == dt.Rows.Count - 1)
                    {
                        lb.Visible = false;
                    }
                }
                else
                {
                    lb.Visible = false;
                }
            }
        }
    }



    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        GridViewRow gvRow = (GridViewRow)lb.NamingContainer;
        int rowID = gvRow.RowIndex + 1;
        if (ViewState["CurrentTable"] != null)
        {
            DataTable dt = (DataTable)ViewState["CurrentTable"];
            if (dt.Rows.Count > 1)
            {
                if (gvRow.RowIndex < dt.Rows.Count - 1)
                {
                    //Remove the Selected Row data
                    dt.Rows.Remove(dt.Rows[rowID]);
                }
            }
            //Store the current data in ViewState for future reference
            ViewState["CurrentTable"] = dt;
            //Re bind the GridView for the updated data
            Gridview1.DataSource = dt;
            Gridview1.DataBind();
        }

        //Set Previous Data on Postbacks
        SetPreviousData();
    }

    // --------------------------ENDS FIRST DATA TABLE ----------------------------------//


    //-----------------------------BEGIN SECOND DATA TABLE------------------------------------//



    private void SetInitialRow2()
    {
        DataTable dt2 = new DataTable();
        DataRow dr2 = null;

        dt2.Columns.Add(new DataColumn("RowNumber2", typeof(string)));
        //dt.Columns.Add(new DataColumn("Date", typeof(string)));

        dt2.Columns.Add(new DataColumn("NT1", typeof(string)));
        //dt.Columns.Add(new DataColumn("NT1_Status", typeof(string)));

        dt2.Columns.Add(new DataColumn("NT1_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("NT2", typeof(string)));
        dt2.Columns.Add(new DataColumn("NT2_Status", typeof(string)));
        //   dt.Columns.Add(new DataColumn("NT2_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("NT3", typeof(string)));
        dt2.Columns.Add(new DataColumn("NT3_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("ICU", typeof(string)));
        dt2.Columns.Add(new DataColumn("ICU_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("SDU", typeof(string)));
        dt2.Columns.Add(new DataColumn("SDU_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("Tele3rd1", typeof(string)));
        dt2.Columns.Add(new DataColumn("Tele3rd1_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("Tele3rd2", typeof(string)));
        dt2.Columns.Add(new DataColumn("Tele3rd2_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("Tele4th1", typeof(string)));
        dt2.Columns.Add(new DataColumn("Tele4th1_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("Tele4th2", typeof(string)));
        dt2.Columns.Add(new DataColumn("Tele4th2_Status", typeof(string)));

        dt2.Columns.Add(new DataColumn("Pedi3rd", typeof(string)));
        dt2.Columns.Add(new DataColumn("Pedi3rd_Status", typeof(string)));

        dt2.Columns.Add(new DataColumn("Pedi4th", typeof(string)));
        dt2.Columns.Add(new DataColumn("Pedi4th_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("PICU_SD", typeof(string)));
        dt2.Columns.Add(new DataColumn("PICU_SD_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("ER", typeof(string)));
        dt2.Columns.Add(new DataColumn("ER_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("MICU", typeof(string)));
        dt2.Columns.Add(new DataColumn("MICU_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("CPV", typeof(string)));
        dt2.Columns.Add(new DataColumn("CPV_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("CVOR", typeof(string)));
        dt2.Columns.Add(new DataColumn("CVOR_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("CLOF", typeof(string)));
        dt2.Columns.Add(new DataColumn("CLOF_Status", typeof(string)));


        dt2.Columns.Add(new DataColumn("CVOR_HOLDING", typeof(string)));
        dt2.Columns.Add(new DataColumn("CVOR_HOLDING_Status", typeof(string)));



        dr2 = dt2.NewRow();
        dr2["RowNumber2"] = 1;
        // dr["Date"] = string.Empty;
        dr2["NT1"] = string.Empty;
        dr2["NT2"] = string.Empty;
        dr2["NT3"] = string.Empty;
        dr2["ICU"] = string.Empty;
        dr2["SDU"] = string.Empty;
        dr2["Tele3rd1"] = string.Empty;
        dr2["Tele3rd2"] = string.Empty;
        dr2["Tele4th1"] = string.Empty;
        dr2["Tele4th2"] = string.Empty;
        dr2["Pedi3rd"] = string.Empty;
        dr2["Pedi4th"] = string.Empty;
        dr2["PICU_SD"] = string.Empty;
        dr2["ER"] = string.Empty;
        dr2["MICU"] = string.Empty;
        dr2["CPV"] = string.Empty;
        dr2["CVOR"] = string.Empty;
        dr2["CLOF"] = string.Empty;
        dr2["CVOR_HOLDING"] = string.Empty;

        dt2.Rows.Add(dr2);
        //dr = dt.NewRow();

        //Store the DataTable in ViewState
        ViewState["CurrentTable"] = dt2;

        Gridview2.DataSource = dt2;
        Gridview2.DataBind();

    }


    private void AddNewRowToGrid2()
    {
        int rowIndex = 0;

        if (ViewState["CurrentTable"] != null)
        {
            DataTable dtCurrentTable2 = (DataTable)ViewState["CurrentTable"];
            DataRow drCurrentRow2 = null;
            if (dtCurrentTable2.Rows.Count > 0)
            {
                for (int i = 1; i <= dtCurrentTable2.Rows.Count; i++)
                {
                    //extract the TextBox  and DropDown values



                    TextBox box1 = (TextBox)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Bed19");
                    DropDownList box2 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment19");

                    TextBox box3 = (TextBox)Gridview2.Rows[rowIndex].Cells[2].FindControl("txt_Bed20");
                    DropDownList box4 = (DropDownList)Gridview2.Rows[rowIndex].Cells[2].FindControl("txt_Comment20");

                    TextBox box5 = (TextBox)Gridview2.Rows[rowIndex].Cells[3].FindControl("txt_Bed21");
                    DropDownList box6 = (DropDownList)Gridview2.Rows[rowIndex].Cells[3].FindControl("txt_Comment21");

                    TextBox box7 = (TextBox)Gridview2.Rows[rowIndex].Cells[4].FindControl("txt_Bed22");
                    DropDownList box8 = (DropDownList)Gridview2.Rows[rowIndex].Cells[4].FindControl("txt_Comment22");

                    TextBox box9 = (TextBox)Gridview2.Rows[rowIndex].Cells[5].FindControl("txt_Bed23");
                    DropDownList box10 = (DropDownList)Gridview2.Rows[rowIndex].Cells[5].FindControl("txt_Comment23");

                    TextBox box11 = (TextBox)Gridview2.Rows[rowIndex].Cells[6].FindControl("txt_Bed24");
                    DropDownList box12 = (DropDownList)Gridview2.Rows[rowIndex].Cells[6].FindControl("txt_Comment24");


                    TextBox box13 = (TextBox)Gridview2.Rows[rowIndex].Cells[7].FindControl("txt_Bed25");
                    DropDownList box14 = (DropDownList)Gridview2.Rows[rowIndex].Cells[7].FindControl("txt_Comment25");

                    TextBox box15 = (TextBox)Gridview2.Rows[rowIndex].Cells[8].FindControl("txt_Bed26");
                    DropDownList box16 = (DropDownList)Gridview2.Rows[rowIndex].Cells[8].FindControl("txt_Comment26");

                    TextBox box17 = (TextBox)Gridview2.Rows[rowIndex].Cells[9].FindControl("txt_Bed27");
                    DropDownList box18 = (DropDownList)Gridview2.Rows[rowIndex].Cells[9].FindControl("txt_Comment27");

                    TextBox box19 = (TextBox)Gridview2.Rows[rowIndex].Cells[10].FindControl("txt_Bed28");
                    DropDownList box20 = (DropDownList)Gridview2.Rows[rowIndex].Cells[10].FindControl("txt_Comment28");


                    TextBox box21 = (TextBox)Gridview2.Rows[rowIndex].Cells[11].FindControl("txt_Bed29");
                    DropDownList box22 = (DropDownList)Gridview2.Rows[rowIndex].Cells[11].FindControl("txt_Comment29");

                    TextBox box23 = (TextBox)Gridview2.Rows[rowIndex].Cells[12].FindControl("txt_Bed30");
                    DropDownList box24 = (DropDownList)Gridview2.Rows[rowIndex].Cells[12].FindControl("txt_Comment30");

                    TextBox box25 = (TextBox)Gridview2.Rows[rowIndex].Cells[13].FindControl("txt_Bed31");
                    DropDownList box26 = (DropDownList)Gridview2.Rows[rowIndex].Cells[13].FindControl("txt_Comment31");

                    TextBox box27 = (TextBox)Gridview2.Rows[rowIndex].Cells[14].FindControl("txt_Bed32");
                    DropDownList box28 = (DropDownList)Gridview2.Rows[rowIndex].Cells[14].FindControl("txt_Comment32");

                    TextBox box29 = (TextBox)Gridview2.Rows[rowIndex].Cells[15].FindControl("txt_Bed33");
                    DropDownList box30 = (DropDownList)Gridview2.Rows[rowIndex].Cells[15].FindControl("txt_Comment33");

                    TextBox box31 = (TextBox)Gridview2.Rows[rowIndex].Cells[16].FindControl("txt_Bed34");
                    DropDownList box32 = (DropDownList)Gridview2.Rows[rowIndex].Cells[16].FindControl("txt_Comment34");

                    TextBox box33 = (TextBox)Gridview2.Rows[rowIndex].Cells[17].FindControl("txt_Bed35");
                    DropDownList box34 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment35");


                    TextBox box35 = (TextBox)Gridview2.Rows[rowIndex].Cells[18].FindControl("txt_Bed36");
                    DropDownList box36 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment36");

                    drCurrentRow2 = dtCurrentTable2.NewRow();


                    drCurrentRow2["RowNumber2"] = i + 1;

                    drCurrentRow2["NT1"] = box1.Text;
                    drCurrentRow2["NT1_Status"] = box2.SelectedValue;


                    drCurrentRow2["NT2"] = box3.Text;
                    drCurrentRow2["NT2_Status"] = box4.SelectedValue;


                    drCurrentRow2["NT3"] = box5.Text;
                    drCurrentRow2["NT3_Status"] = box6.SelectedValue;


                    drCurrentRow2["ICU"] = box7.Text;
                    drCurrentRow2["ICU_Status"] = box8.SelectedValue;

                    // drCurrentRow["SDU_Census"] = box1.Text;
                    drCurrentRow2["SDU"] = box9.Text;
                    drCurrentRow2["SDU_Status"] = box10.SelectedValue;

                    //drCurrentRow["Tele3rd1_Census"] = box1.Text;
                    drCurrentRow2["Tele3rd1"] = box11.Text;
                    drCurrentRow2["Tele3rd1_Status"] = box12.SelectedValue;

                    //drCurrentRow["Tele3rd2_Census"] = box1.Text;
                    drCurrentRow2["Tele3rd2"] = box13.Text;
                    drCurrentRow2["Tele3rd2_Status"] = box14.SelectedValue;

                    //drCurrentRow["Tele4th1_Census"] = box1.Text;
                    drCurrentRow2["Tele4th1"] = box15.Text;
                    drCurrentRow2["Tele4th1_Status"] = box16.SelectedValue;

                    //drCurrentRow["Tele4th2_Census"] = box1.Text;
                    drCurrentRow2["Tele4th2"] = box17.Text;
                    drCurrentRow2["Tele4th2_Status"] = box18.SelectedValue;

                    //drCurrentRow["Pedi3rd_Census"] = box1.Text;
                    drCurrentRow2["Pedi3rd"] = box19.Text;
                    drCurrentRow2["Pedi3rd_Status"] = box20.SelectedValue;

                    //drCurrentRow["Pedi4th_Census"] = box1.Text;
                    drCurrentRow2["Pedi4th"] = box21.Text;
                    drCurrentRow2["Pedi4th_Status"] = box22.SelectedValue;

                    // drCurrentRow["PICU_SD_Census"] = box1.Text;
                    drCurrentRow2["PICU_SD"] = box23.Text;
                    drCurrentRow2["PICU_SD_Status"] = box24.SelectedValue;

                    //drCurrentRow["ER_Census"] = box1.Text;
                    drCurrentRow2["ER"] = box25.Text;
                    drCurrentRow2["ER_Status"] = box26.SelectedValue;

                    // drCurrentRow["MICU_Census"] = box1.Text;
                    drCurrentRow2["MICU"] = box27.Text;
                    drCurrentRow2["MICU_Status"] = box28.SelectedValue;

                    //drCurrentRow["CPV_Census"] = box1.Text;
                    drCurrentRow2["CPV"] = box29.Text;
                    drCurrentRow2["CPV_Status"] = box30.SelectedValue;

                    //drCurrentRow["CVOR_Census"] = box1.Text;
                    drCurrentRow2["CVOR"] = box31.Text;
                    drCurrentRow2["CVOR_Status"] = box32.SelectedValue;

                    drCurrentRow2["CLOF"] = box33.Text;
                    drCurrentRow2["CLOF_Status"] = box34.SelectedValue;


                    //drCurrentRow["CVOR_HOLDING_Census"] = box1.Text;
                    drCurrentRow2["CVOR_HOLDING"] = box35.Text;
                    drCurrentRow2["CVOR_HOLDING_Status"] = box36.SelectedValue;

                    rowIndex++;
                }


                dtCurrentTable2.Rows.Add(drCurrentRow2);
                ViewState["CurrentTable"] = dtCurrentTable2;

                Gridview2.DataSource = dtCurrentTable2;
                Gridview2.DataBind();
            }
        }
        else
        {
            Response.Write("ViewState is null");
        }

        //Set Previous Data on Postbacks
        SetPreviousData2();
    }


    private void SetPreviousData2()
    {
        int rowIndex = 0;
        if (ViewState["CurrentTable"] != null)
        {
            DataTable dt2 = (DataTable)ViewState["CurrentTable"];
            if (dt2.Rows.Count > 0)
            {
                for (int i = 1; i < dt2.Rows.Count; i++)
                {


                    TextBox box1 = (TextBox)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Bed19");
                    DropDownList box2 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment19");

                    TextBox box3 = (TextBox)Gridview2.Rows[rowIndex].Cells[2].FindControl("txt_Bed20");
                    DropDownList box4 = (DropDownList)Gridview2.Rows[rowIndex].Cells[2].FindControl("txt_Comment20");

                    TextBox box5 = (TextBox)Gridview2.Rows[rowIndex].Cells[3].FindControl("txt_Bed21");
                    DropDownList box6 = (DropDownList)Gridview2.Rows[rowIndex].Cells[3].FindControl("txt_Comment21");

                    TextBox box7 = (TextBox)Gridview2.Rows[rowIndex].Cells[4].FindControl("txt_Bed22");
                    DropDownList box8 = (DropDownList)Gridview2.Rows[rowIndex].Cells[4].FindControl("txt_Comment22");

                    TextBox box9 = (TextBox)Gridview2.Rows[rowIndex].Cells[5].FindControl("txt_Bed23");
                    DropDownList box10 = (DropDownList)Gridview2.Rows[rowIndex].Cells[5].FindControl("txt_Comment23");

                    TextBox box11 = (TextBox)Gridview2.Rows[rowIndex].Cells[6].FindControl("txt_Bed24");
                    DropDownList box12 = (DropDownList)Gridview2.Rows[rowIndex].Cells[6].FindControl("txt_Comment24");


                    TextBox box13 = (TextBox)Gridview2.Rows[rowIndex].Cells[7].FindControl("txt_Bed25");
                    DropDownList box14 = (DropDownList)Gridview2.Rows[rowIndex].Cells[7].FindControl("txt_Comment25");

                    TextBox box15 = (TextBox)Gridview2.Rows[rowIndex].Cells[8].FindControl("txt_Bed26");
                    DropDownList box16 = (DropDownList)Gridview2.Rows[rowIndex].Cells[8].FindControl("txt_Comment26");

                    TextBox box17 = (TextBox)Gridview2.Rows[rowIndex].Cells[9].FindControl("txt_Bed27");
                    DropDownList box18 = (DropDownList)Gridview2.Rows[rowIndex].Cells[9].FindControl("txt_Comment27");

                    TextBox box19 = (TextBox)Gridview2.Rows[rowIndex].Cells[10].FindControl("txt_Bed28");
                    DropDownList box20 = (DropDownList)Gridview2.Rows[rowIndex].Cells[10].FindControl("txt_Comment28");


                    TextBox box21 = (TextBox)Gridview2.Rows[rowIndex].Cells[11].FindControl("txt_Bed29");
                    DropDownList box22 = (DropDownList)Gridview2.Rows[rowIndex].Cells[11].FindControl("txt_Comment29");

                    TextBox box23 = (TextBox)Gridview2.Rows[rowIndex].Cells[12].FindControl("txt_Bed30");
                    DropDownList box24 = (DropDownList)Gridview2.Rows[rowIndex].Cells[12].FindControl("txt_Comment30");

                    TextBox box25 = (TextBox)Gridview2.Rows[rowIndex].Cells[13].FindControl("txt_Bed31");
                    DropDownList box26 = (DropDownList)Gridview2.Rows[rowIndex].Cells[13].FindControl("txt_Comment31");

                    TextBox box27 = (TextBox)Gridview2.Rows[rowIndex].Cells[14].FindControl("txt_Bed32");
                    DropDownList box28 = (DropDownList)Gridview2.Rows[rowIndex].Cells[14].FindControl("txt_Comment32");

                    TextBox box29 = (TextBox)Gridview2.Rows[rowIndex].Cells[15].FindControl("txt_Bed33");
                    DropDownList box30 = (DropDownList)Gridview2.Rows[rowIndex].Cells[15].FindControl("txt_Comment33");

                    TextBox box31 = (TextBox)Gridview2.Rows[rowIndex].Cells[16].FindControl("txt_Bed34");
                    DropDownList box32 = (DropDownList)Gridview2.Rows[rowIndex].Cells[16].FindControl("txt_Comment34");

                    TextBox box33 = (TextBox)Gridview2.Rows[rowIndex].Cells[17].FindControl("txt_Bed35");
                    DropDownList box34 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment35");


                    TextBox box35 = (TextBox)Gridview2.Rows[rowIndex].Cells[18].FindControl("txt_Bed36");
                    DropDownList box36 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment36");

                    // Assign Values to textboxes


                    box1.Text = dt2.Rows[i]["NT1"].ToString();
                    box2.Text = dt2.Rows[i]["NT1_Status"].ToString();


                    box3.Text = dt2.Rows[i]["NT2"].ToString();
                    box4.Text = dt2.Rows[i]["NT2_Status"].ToString();


                    box5.Text = dt2.Rows[i]["NT3"].ToString();
                    box6.Text = dt2.Rows[i]["NT3_Status"].ToString();


                    box7.Text = dt2.Rows[i]["ICU"].ToString();
                    box8.Text = dt2.Rows[i]["ICU_Status"].ToString();


                    box9.Text = dt2.Rows[i]["SDU"].ToString();
                    box10.Text = dt2.Rows[i]["SDU_Status"].ToString();


                    box11.Text = dt2.Rows[i]["Tele3rd1"].ToString();
                    box12.Text = dt2.Rows[i]["Tele3rd1_Status"].ToString();


                    box13.Text = dt2.Rows[i]["Tele3rd2"].ToString();
                    box14.Text = dt2.Rows[i]["Tele3rd2_Status"].ToString();


                    box15.Text = dt2.Rows[i]["Tele4th1"].ToString();
                    box16.Text = dt2.Rows[i]["Tele4th1_Status"].ToString();


                    box17.Text = dt2.Rows[i]["Tele4th2"].ToString();
                    box18.Text = dt2.Rows[i]["Tele4th2_Status"].ToString();


                    box19.Text = dt2.Rows[i]["Pedi3rd"].ToString();
                    box20.Text = dt2.Rows[i]["Pedi3rd_Status"].ToString();


                    box21.Text = dt2.Rows[i]["Pedi4th"].ToString();
                    box22.Text = dt2.Rows[i]["Pedi4th_Status"].ToString();


                    box23.Text = dt2.Rows[i]["PICU_SD"].ToString();
                    box24.Text = dt2.Rows[i]["PICU_SD_Status"].ToString();


                    box25.Text = dt2.Rows[i]["ER"].ToString();
                    box26.Text = dt2.Rows[i]["ER_Status"].ToString();


                    box27.Text = dt2.Rows[i]["MICU"].ToString();
                    box28.Text = dt2.Rows[i]["MICU_Status"].ToString();


                    box29.Text = dt2.Rows[i]["CPV"].ToString();
                    box30.Text = dt2.Rows[i]["CPV_Status"].ToString();


                    box31.Text = dt2.Rows[i]["CVOR"].ToString();
                    box32.Text = dt2.Rows[i]["CVOR_Status"].ToString();


                    box33.Text = dt2.Rows[i]["CLOF"].ToString();
                    box34.Text = dt2.Rows[i]["CLOF_Status"].ToString();


                    box35.Text = dt2.Rows[i]["CVOR_HOLDING"].ToString();
                    box36.Text = dt2.Rows[i]["CVOR_HOLDING_Status"].ToString();

                    rowIndex++;

                }
            }
            // ViewState["CurrentTable"] = dt;

        }
    }



    protected void ButtonAdd2_Click(object sender, EventArgs e)
    {
        AddNewRowToGrid2();
    }




    protected void Button2_Click(object sender, EventArgs e)
    {
        int rowIndex = 0;
        StringCollection sc = new StringCollection();
        if (ViewState["CurrentTable"] != null)
        {
            DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
            if (dtCurrentTable.Rows.Count > 0)
            {
                for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                {
                    //extract the TextBox and DropDowns values

                    TextBox box1 = (TextBox)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Bed19");
                    DropDownList box2 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment19");

                    TextBox box3 = (TextBox)Gridview2.Rows[rowIndex].Cells[2].FindControl("txt_Bed20");
                    DropDownList box4 = (DropDownList)Gridview2.Rows[rowIndex].Cells[2].FindControl("txt_Comment20");

                    TextBox box5 = (TextBox)Gridview2.Rows[rowIndex].Cells[3].FindControl("txt_Bed21");
                    DropDownList box6 = (DropDownList)Gridview2.Rows[rowIndex].Cells[3].FindControl("txt_Comment21");

                    TextBox box7 = (TextBox)Gridview2.Rows[rowIndex].Cells[4].FindControl("txt_Bed22");
                    DropDownList box8 = (DropDownList)Gridview2.Rows[rowIndex].Cells[4].FindControl("txt_Comment22");

                    TextBox box9 = (TextBox)Gridview2.Rows[rowIndex].Cells[5].FindControl("txt_Bed23");
                    DropDownList box10 = (DropDownList)Gridview2.Rows[rowIndex].Cells[5].FindControl("txt_Comment23");

                    TextBox box11 = (TextBox)Gridview2.Rows[rowIndex].Cells[6].FindControl("txt_Bed24");
                    DropDownList box12 = (DropDownList)Gridview2.Rows[rowIndex].Cells[6].FindControl("txt_Comment24");


                    TextBox box13 = (TextBox)Gridview2.Rows[rowIndex].Cells[7].FindControl("txt_Bed25");
                    DropDownList box14 = (DropDownList)Gridview2.Rows[rowIndex].Cells[7].FindControl("txt_Comment25");

                    TextBox box15 = (TextBox)Gridview2.Rows[rowIndex].Cells[8].FindControl("txt_Bed26");
                    DropDownList box16 = (DropDownList)Gridview2.Rows[rowIndex].Cells[8].FindControl("txt_Comment26");

                    TextBox box17 = (TextBox)Gridview2.Rows[rowIndex].Cells[9].FindControl("txt_Bed27");
                    DropDownList box18 = (DropDownList)Gridview2.Rows[rowIndex].Cells[9].FindControl("txt_Comment27");

                    TextBox box19 = (TextBox)Gridview2.Rows[rowIndex].Cells[10].FindControl("txt_Bed28");
                    DropDownList box20 = (DropDownList)Gridview2.Rows[rowIndex].Cells[10].FindControl("txt_Comment28");


                    TextBox box21 = (TextBox)Gridview2.Rows[rowIndex].Cells[11].FindControl("txt_Bed29");
                    DropDownList box22 = (DropDownList)Gridview2.Rows[rowIndex].Cells[11].FindControl("txt_Comment29");

                    TextBox box23 = (TextBox)Gridview2.Rows[rowIndex].Cells[12].FindControl("txt_Bed30");
                    DropDownList box24 = (DropDownList)Gridview2.Rows[rowIndex].Cells[12].FindControl("txt_Comment30");

                    TextBox box25 = (TextBox)Gridview2.Rows[rowIndex].Cells[13].FindControl("txt_Bed31");
                    DropDownList box26 = (DropDownList)Gridview2.Rows[rowIndex].Cells[13].FindControl("txt_Comment31");

                    TextBox box27 = (TextBox)Gridview2.Rows[rowIndex].Cells[14].FindControl("txt_Bed32");
                    DropDownList box28 = (DropDownList)Gridview2.Rows[rowIndex].Cells[14].FindControl("txt_Comment32");

                    TextBox box29 = (TextBox)Gridview2.Rows[rowIndex].Cells[15].FindControl("txt_Bed33");
                    DropDownList box30 = (DropDownList)Gridview2.Rows[rowIndex].Cells[15].FindControl("txt_Comment33");

                    TextBox box31 = (TextBox)Gridview2.Rows[rowIndex].Cells[16].FindControl("txt_Bed34");
                    DropDownList box32 = (DropDownList)Gridview2.Rows[rowIndex].Cells[16].FindControl("txt_Comment34");

                    TextBox box33 = (TextBox)Gridview2.Rows[rowIndex].Cells[17].FindControl("txt_Bed35");
                    DropDownList box34 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment35");


                    TextBox box35 = (TextBox)Gridview2.Rows[rowIndex].Cells[18].FindControl("txt_Bed36");
                    DropDownList box36 = (DropDownList)Gridview2.Rows[rowIndex].Cells[1].FindControl("txt_Comment36");

                    DateTime datevar = DateTime.Parse(dateLabel.Text.ToString());
                    String dateLabelFx = DateTime.Now.ToString("dd MMMM yyyy HH:mm");

                    // Noth Tower Header Census


                    TextBox NT1Census = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census19");
                    TextBox NT2Census = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census20");
                    TextBox NT3Census = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census21");
                    TextBox ICUCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census22");
                    TextBox SDUCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census23");
                    TextBox Tele3rd1Census = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census24");
                    TextBox Tele3rd2Census = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census25");
                    TextBox Tele4th1Census = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census26");
                    TextBox Tele4th2Census = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census27");
                    TextBox Pedi3rdCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census28");
                    TextBox Pedi4thCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census29");
                    TextBox PICUCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census30");
                    TextBox MICUCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census31");
                    TextBox ERCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census32");
                    TextBox CPUCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census33");
                    TextBox CVORCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census34");
                    TextBox CLOFCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census35");
                    TextBox CVORHCensus = (TextBox)Gridview2.HeaderRow.FindControl("txt_Census36");




                    //get the values from the TextBoxes
                    //then add it to the collections with a comma "," as the delimited values
                    sc.Add(dateLabelFx + "," + NT1Census.Text + "," + NT2Census.Text + "," + NT3Census.Text + "," + ICUCensus.Text + "," + SDUCensus.Text + "," + Tele3rd1Census.Text + "," + Tele3rd2Census.Text + "," + Tele4th1Census.Text + "," + Tele4th2Census.Text + "," + Pedi3rdCensus.Text + "," + Pedi4thCensus.Text + "," + PICUCensus.Text + "," + MICUCensus.Text + "," + ERCensus.Text + "," + CPUCensus.Text + "," + CVORCensus.Text + "," + CLOFCensus.Text + "," + CVORHCensus.Text + "," + box1.Text + "," + box2.Text + "," + box3.Text + "," + box4.Text + "," + box5.Text + "," + box6.Text + "," + box7.Text + "," + box8.Text + "," + box9.Text + "," + box10.Text + "," + box11.Text + "," + box12.Text + "," + box13.Text + "," + box14.Text + "," + box15.Text + "," + box16.Text + "," + box17.Text + "," + box18.Text + "," + box19.Text + "," + box20.Text + "," + box21.Text + "," + box22.Text + "," + box23.Text + "," + box24.Text + "," + box25.Text + "," + box26.Text + "," + box27.Text + "," + box28.Text + "," + box29.Text + "," + box30.Text + "," + box31.Text + "," + box32.Text + "," + box33.Text + "," + box34.Text + "," + box35.Text + "," + box36.Text + ",");
                    rowIndex++;
                }
                //Call the method for executing inserts from main grid
                InsertRecords2(sc);


            }
        }
    }
    //A method that returns a string which calls the connection string from the web.config
    private string GetConnectionString2()
    {
        //"DBConnection" is the name of the Connection String
        //that was set up from the web.config file
        return System.Configuration.ConfigurationManager.ConnectionStrings["appdevConnectionString2"].ConnectionString;
    }
    //A method that Inserts the records to the database
    private void InsertRecords2(StringCollection sc)
    {

        SqlConnection conn = new SqlConnection(GetConnectionString2());
        StringBuilder sb = new StringBuilder(string.Empty);


        string[] splitItems = null;


        foreach (string item in sc)
        {

            const string sqlStatement = "INSERT INTO tb_Bed_Control_Possible (Date,NT1_Census,NT2_Census,NT3_Census,ICU_Census,SDU_Census,Tele3rd1_Census,Tele3rd2_Census,Tele4th1_Census,Tele4th2_Census,Pedi3rd_Census,Pedi4th_Census,PICU_SD_Census,ER_Census,MICU_Census,CPV_Census,CVOR_Census,CLOF_Census,CVOR_HOLDING_Census,NT1,NT1_Status,NT2,NT2_Status,NT3,NT3_Status,ICU,ICU_Status,SDU,SDU_Status,Tele3rd1,Tele3rd1_Status,Tele3rd2,Tele3rd2_Status,Tele4th1,Tele4th1_Status,Tele4th2,Tele4th2_Status,Pedi3rd,Pedi3rd_Status,Pedi4th,Pedi4th_Status,PICU_SD,PICU_SD_Status,ER,ER_Status,MICU,MICU_Status,CPV,CPV_Status,CVOR,CVOR_Status,CLOF,CLOF_Status,CVOR_HOLDING,CVOR_HOLDING_Status) VALUES";


            if (item.Contains(","))
            {
                splitItems = item.Split(",".ToCharArray());

                sb.AppendFormat("{0}('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}','{38}','{39}','{40}','{41}','{42}','{43}','{44}','{45}','{46}','{47}','{48}','{49}','{50}','{51}','{52}','{53}','{54}','{55}'); ", sqlStatement, splitItems[0], splitItems[1], splitItems[2], splitItems[3], splitItems[4], splitItems[5], splitItems[6], splitItems[7], splitItems[8], splitItems[9], splitItems[10], splitItems[11], splitItems[12], splitItems[13], splitItems[14], splitItems[15], splitItems[16], splitItems[17], splitItems[18], splitItems[19], splitItems[20], splitItems[21], splitItems[22], splitItems[23], splitItems[24], splitItems[25], splitItems[26], splitItems[27], splitItems[28], splitItems[29], splitItems[30], splitItems[31], splitItems[32], splitItems[33], splitItems[34], splitItems[35], splitItems[36], splitItems[37], splitItems[38], splitItems[39], splitItems[40], splitItems[41], splitItems[42], splitItems[43], splitItems[44], splitItems[45], splitItems[46], splitItems[47], splitItems[48], splitItems[49], splitItems[50], splitItems[51], splitItems[52], splitItems[53], splitItems[54]);

            }

        }

        try
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand(sb.ToString(), conn);


            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();

            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Pending Beds Succesfully Updated');", true);

        }
        catch (System.Data.SqlClient.SqlException ex)
        {
            string msg = "Insert Error:";
            msg += ex.Message;
            throw new Exception(msg);

        }
        finally
        {
            conn.Close();
        }
    }
    // Hide the Remove Button at the last row of the GridView
    protected void Gridview2_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataTable dt = (DataTable)ViewState["CurrentTable"];
            LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1");
            if (lb != null)
            {
                if (dt.Rows.Count > 1)
                {
                    if (e.Row.RowIndex == dt.Rows.Count - 1)
                    {
                        lb.Visible = false;
                    }
                }
                else
                {
                    lb.Visible = false;
                }
            }
        }
    }



    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        LinkButton lb = (LinkButton)sender;
        GridViewRow gvRow = (GridViewRow)lb.NamingContainer;
        int rowID = gvRow.RowIndex + 1;
        if (ViewState["CurrentTable"] != null)
        {
            DataTable dt = (DataTable)ViewState["CurrentTable"];
            if (dt.Rows.Count > 1)
            {
                if (gvRow.RowIndex < dt.Rows.Count - 1)
                {
                    //Remove the Selected Row data
                    dt.Rows.Remove(dt.Rows[rowID]);
                }
            }
            //Store the current data in ViewState for future reference
            ViewState["CurrentTable"] = dt;
            //Re bind the GridView for the updated data
            Gridview1.DataSource = dt;
            Gridview1.DataBind();
        }

        //Set Previous Data on Postbacks
        SetPreviousData();
    }




    //END OF CLASS 

}






aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GridViewWithTextBoxes" Debug="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css" media="screen"/>
<title>DHR Bed Control</title>
         
    <style type="text/css">
        .style2
        {
            color: #579;
            font-size: 13px;
            font-weight: bold;
            margin: 4px;
            text-align: center;
            }
        .style3
        {
            text-align: center;
        }
        .dateFont
        {
            text-align: center;
        }
        .style4
        {
            text-align: left;
        }
        .style5
        {
            width: auto;
            line-height: 20px;
            color: #557799;
            font-size: 12px;
            padding: 5px 6px 0px 6px;
            background-color: #FDFDFD;
            border: 1px solid #efefef;
            text-align: justify;
            height: auto;
            text-decoration: underline;
        }
    </style>
 
</head>


<body>
    <form id="form1" runat="server">
<div class="main">

<h4 class="style3">&nbsp;Doctors Hospital at Renaissance - Bed Control</h4>

<h2><asp:Label ID="dateLabel" runat="server" CssClass="dateFont"></asp:Label></h2>

<div class="topb"></div>

<div class="content">


<!-- News block start -->

<div class="insidebox">
<div class="style2">
    <div class="style4">
    AVAILABLE BEDS

    </div>
    </br>
    <div>
      <asp:gridview ID="Gridview1" runat="server" ShowFooter="True" 
            AutoGenerateColumns="False" onrowcreated="Gridview1_RowCreated" 
            EnableModelValidation="True">
            
            <Columns>
         
            <asp:BoundField DataField="RowNumber" HeaderText="Row Number" ControlStyle-Width="25%" />
            <asp:TemplateField  ControlStyle-Width="25%">
               <HeaderTemplate  >
               <asp:Label ID="Label1" runat="server">NT-1</asp:Label>
            
            <asp:TextBox ID="txt_Census1" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="zero" />
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="zero" />


                <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed1" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment1" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
            </asp:TemplateField>


            <asp:TemplateField >
            <HeaderTemplate  >
               <asp:Label ID="Label2" runat="server">NT-2</asp:Label>
            
            <asp:TextBox ID="txt_Census2" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

                 <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed2" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment2" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
            </asp:TemplateField>


            <asp:TemplateField >
            <HeaderTemplate  >
               <asp:Label ID="Label3" runat="server">NT-3</asp:Label>
            
            <asp:TextBox ID="txt_Census3" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
                 <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed3" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment3" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField >
            <HeaderTemplate  >
            <asp:Label ID="Label4" runat="server">ICU</asp:Label>
            <asp:TextBox ID="txt_Census4" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
                 
             <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed4" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment4" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
              </asp:TemplateField>


       <asp:TemplateField >
       <HeaderTemplate  >
               <asp:Label ID="Label5" runat="server">SDU</asp:Label>
            
            <asp:TextBox ID="txt_Census5" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

           <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed5" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment5" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
     </asp:TemplateField>


        <asp:TemplateField >

        <HeaderTemplate  >
               <asp:Label ID="Label6" runat="server">Tele 3rd-1</asp:Label>
            
            <asp:TextBox ID="txt_Census6" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

                  <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed6" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment6" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
       </asp:TemplateField>

     <asp:TemplateField >
          <HeaderTemplate  >
               <asp:Label ID="Label7" runat="server">Tele 3rd-2</asp:Label>
            
            <asp:TextBox ID="txt_Census7" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
                
                      <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed7" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment7" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
 </asp:TemplateField>

        <asp:TemplateField >
             <HeaderTemplate  >
               <asp:Label ID="Label8" runat="server">Tele 4th-1</asp:Label>
            
            <asp:TextBox ID="txt_Census8" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
                     <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed8" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment8" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField >
                 <HeaderTemplate  >
               <asp:Label ID="Label9" runat="server">Tele 4th-2</asp:Label>
            
            <asp:TextBox ID="txt_Census9" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

            <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed9" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment9" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
                </asp:TemplateField>


         <asp:TemplateField >
            <HeaderTemplate  >
            <asp:Label ID="Label10" runat="server">Pedi 3th</asp:Label>
            <asp:TextBox ID="txt_Census10" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

            <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed10" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment10" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
        </asp:TemplateField>

        
          <asp:TemplateField >
            <HeaderTemplate  >
            <asp:Label ID="Label11" runat="server">Pedi 4th</asp:Label>
            <asp:TextBox ID="txt_Census11" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

             <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed11" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment11" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
        </asp:TemplateField>


           <asp:TemplateField >
             <HeaderTemplate  >
               <asp:Label ID="Label12" runat="server">PICU/SD</asp:Label>
            
            <asp:TextBox ID="txt_Census12" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

             <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed12" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment12" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
         </asp:TemplateField>


                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label13" runat="server">MICU</asp:Label>
            
            <asp:TextBox ID="txt_Census13" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

                  <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed13" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment13" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
          </asp:TemplateField>

                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label14" runat="server">ER</asp:Label>
            
            <asp:TextBox ID="txt_Census14" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
            <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed14" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment14" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
        </asp:TemplateField>


                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label15" runat="server">CPU</asp:Label>
            
            <asp:TextBox ID="txt_Census15" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
            <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed15" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment15" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
      </asp:TemplateField>


                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label16" runat="server">CVOR</asp:Label>
            
            <asp:TextBox ID="txt_Census16" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

          <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed16" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment16" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
      </asp:TemplateField>
      

    <asp:TemplateField >
      <HeaderTemplate  >
               <asp:Label ID="Label17" runat="server">CLOF</asp:Label>
            
            <asp:TextBox ID="txt_Census17" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
              <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed17" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment17" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
                </asp:TemplateField>


                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label18" runat="server">CVOR H</asp:Label>
            
            <asp:TextBox ID="txt_Census18" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
              <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed18" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment18" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>

                <FooterStyle HorizontalAlign="Right" />
                <FooterTemplate>
                 <asp:Button ID="ButtonAdd" runat="server" Text="Add New Row" 
                        onclick="ButtonAdd_Click" Width="130px" />
                </FooterTemplate>

                </asp:TemplateField>
            </Columns>
        </asp:gridview>
    </div>
  

<!-- News block end -->

<!-- news block start -->

</div>

<asp:Button ID="Button1" runat="server" Text="Save" onclick="Button1_Click" />
</br>
<div class="style5"><strong>PENDING / POSSIBLE DISCHAGES</strong></div>
</br>
<div>


      <asp:gridview ID="Gridview2" runat="server" ShowFooter="True" 
            AutoGenerateColumns="False" onrowcreated="Gridview2_RowCreated" 
            EnableModelValidation="True">
            
            <Columns>
         
            <asp:BoundField DataField="RowNumber2" HeaderText="Row Number" />
            <asp:TemplateField >
               <HeaderTemplate  >
               <asp:Label ID="Label2" runat="server">NT-1</asp:Label>
            
            <asp:TextBox ID="txt_Census19" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>


                <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed19" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment19" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
            </asp:TemplateField>


            <asp:TemplateField >
            <HeaderTemplate  >
               <asp:Label ID="Label20" runat="server">NT-2</asp:Label>
            
            <asp:TextBox ID="txt_Census20" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

                 <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed20" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment20" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
            </asp:TemplateField>


            <asp:TemplateField >
            <HeaderTemplate  >
               <asp:Label ID="Label21" runat="server">NT-3</asp:Label>
            
            <asp:TextBox ID="txt_Census21" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
                 <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed21" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment21" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField >
            <HeaderTemplate  >
            <asp:Label ID="Label22" runat="server">ICU</asp:Label>
            <asp:TextBox ID="txt_Census22" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
                 
             <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed22" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment22" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
              </asp:TemplateField>


       <asp:TemplateField >
       <HeaderTemplate  >
               <asp:Label ID="Label23" runat="server">SDU</asp:Label>
            
            <asp:TextBox ID="txt_Census23" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

           <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed23" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment23" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
     </asp:TemplateField>


        <asp:TemplateField >

        <HeaderTemplate  >
               <asp:Label ID="Label24" runat="server">Tele 3rd-1</asp:Label>
            
            <asp:TextBox ID="txt_Census24" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

                  <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed24" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment24" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
       </asp:TemplateField>

     <asp:TemplateField >
          <HeaderTemplate  >
               <asp:Label ID="Label25" runat="server">Tele 3rd-2</asp:Label>
            
            <asp:TextBox ID="txt_Census25" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
                
                      <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed25" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment25" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
 </asp:TemplateField>

        <asp:TemplateField >
             <HeaderTemplate  >
               <asp:Label ID="Label26" runat="server">Tele 4th-1</asp:Label>
            
            <asp:TextBox ID="txt_Census26" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
                     <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed26" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment26" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField >
                 <HeaderTemplate  >
               <asp:Label ID="Label27" runat="server">Tele 4th-2</asp:Label>
            
            <asp:TextBox ID="txt_Census27" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

            <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed27" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment27" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
                </asp:TemplateField>


         <asp:TemplateField >
            <HeaderTemplate  >
            <asp:Label ID="Label28" runat="server">Pedi 3th</asp:Label>
            <asp:TextBox ID="txt_Census28" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

            <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed28" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment28" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
        </asp:TemplateField>

        
          <asp:TemplateField >
            <HeaderTemplate  >
            <asp:Label ID="Label29" runat="server">Pedi 4th</asp:Label>
            <asp:TextBox ID="txt_Census29" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

             <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed29" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment29" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
        </asp:TemplateField>


           <asp:TemplateField >
             <HeaderTemplate  >
               <asp:Label ID="Label30" runat="server">PICU/SD</asp:Label>
            
            <asp:TextBox ID="txt_Census30" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

             <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed30" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment30" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
         </asp:TemplateField>


                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label31" runat="server">MICU</asp:Label>
            
            <asp:TextBox ID="txt_Census31" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

                  <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed31" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment31" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
          </asp:TemplateField>

                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label32" runat="server">ER</asp:Label>
            
            <asp:TextBox ID="txt_Census32" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
            <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed32" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment32" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
        </asp:TemplateField>


                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label33" runat="server">CPU</asp:Label>
            
            <asp:TextBox ID="txt_Census33" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
            <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed33" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment33" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
      </asp:TemplateField>


                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label34" runat="server">CVOR</asp:Label>
            
            <asp:TextBox ID="txt_Census34" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>

          <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed34" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment34" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
      </asp:TemplateField>
      

    <asp:TemplateField >
      <HeaderTemplate  >
               <asp:Label ID="Label35" runat="server">CLOF</asp:Label>
            
            <asp:TextBox ID="txt_Census35" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
              <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed35" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment35" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>
                </asp:TemplateField>


                <asp:TemplateField >
                  <HeaderTemplate  >
               <asp:Label ID="Label36" runat="server">CVOR H</asp:Label>
            
            <asp:TextBox ID="txt_Census36" runat="server" Width="50px" ></asp:TextBox>
            </HeaderTemplate>
              <ItemTemplate>
                    Bed:
                    <asp:TextBox ID="txt_Bed36" runat="server" Width="50px"></asp:TextBox>
                    Status:
                    <asp:DropDownList ID="txt_Comment36" runat="server" AppendDataBoundItems="True" 
                    style="text-align: left" >
                    <asp:ListItem value="0" text="Select">  </asp:ListItem>
                    <asp:ListItem>Assigned</asp:ListItem>
                    <asp:ListItem>Blocked Room</asp:ListItem>
                    <asp:ListItem>Open NS</asp:ListItem>
                                      
                </asp:DropDownList>

                </ItemTemplate>

                <FooterStyle HorizontalAlign="Right" />
                <FooterTemplate>
                 <asp:Button ID="ButtonAdd2" runat="server" Text="Add New Row" 
                        onclick="ButtonAdd2_Click" Width="130px" />
                </FooterTemplate>

                </asp:TemplateField>
            </Columns>
        </asp:gridview>

<br />
</div>
<!-- news block end -->


	</div>


<!-- leave the class="clearer" - no floating on left or right side leave this or if
 you like playing around try to remove it and see what happens :P -->

<div class="clearer"><span>

    <asp:Button ID="Button2" runat="server" Text="Save" onclick="Button2_Click" />

    
    </span></div>

    
       <div style="text-align: left">Behavioral Census:
           <asp:TextBox ID="txtCensusWomens" runat="server" Height="22px" 
               style="text-align: right" Text='<%# Bind("Womens_Census") %>' Width="97px"></asp:TextBox>
           &nbsp;&nbsp;&nbsp;
           Women Census:
           <asp:TextBox ID="txtCensusBehavioral" runat="server" Height="23px" 
               Text='<%# Bind("Behavioral_Census") %>' Width="97px"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rehab Census:
           <asp:TextBox ID="txtCensusREHAB" runat="server" Height="23px" 
               Text='<%# Bind("Rehab_Census") %>' Width="91px"></asp:TextBox>
        </div>

</form>
</body>
</html>

Open in new window

0
Comment
Question by:TonyReba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 35048058
At line 733 you use:
dt2.Columns.Add(new DataColumn("RowNumber2", typeof(string)));
it should be:
dt2.Columns.Add(new DataColumn("RowNumber", typeof(string)));

RowNumber does not exit in your table because the definition is for RowNumber2
0
 
LVL 9

Author Comment

by:TonyReba
ID: 35048162
So the viewstate should know which table is which table, for the Gridvuew?
0
 
LVL 9

Author Comment

by:TonyReba
ID: 35048197
at line 814 I get now

Column 'RowNumber2' does not belong to table .
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Author Comment

by:TonyReba
ID: 35048246
I think I found my error , just want one more opinion on it.,..

So I dont get errors now, but havent tested on the actual site with the database, but the error seemed to be the name for Viewstate[CurrentTable]


In the first one , Gridview1 ,I used
CurrentTable
and second Gridview , Gridview2
CurrentTable2

Would that work?
0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 35053292
Yes, it will work as long as the name is unique. (ViewState behaves as a dictionary)
Note: Glad I solved your issue, just remember that I have not checked your whole code as I focus on solving your question only, if your code has more issues(different from question) please post them in a separate question.
0
 
LVL 9

Author Closing Comment

by:TonyReba
ID: 35056674
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Build a string of emails from a gridview 2 31
C# LINQ 5 45
Easiest intro into .NET CORE? 2 34
Javascript function 3 23
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question