protected void LinkDeleteInf_Click(object sender, EventArgs e)
        {
            LinkButton  lb    = (LinkButton)sender;
            GridViewRow gvRow = (GridViewRow)lb.NamingContainer;
            int         rowID = gvRow.RowIndex;

            if (ViewState["CurrentTableInf"] != null)
            {
                DataTable dt = (DataTable)ViewState["CurrentTableInf"];
                if (dt.Rows.Count > 1)
                {
                    if (gvRow.RowIndex < dt.Rows.Count - 1)
                    {
                        //Remove the Selected Row data and reset row number
                        dt.Rows.Remove(dt.Rows[rowID]);
                        ResetRowIDInf(dt);
                    }
                }

                //Store the current data in ViewState for future reference
                ViewState["CurrentTableInf"] = dt;

                //Re bind the GridView for the updated data
                GridviewInf.DataSource = dt;
                GridviewInf.DataBind();
            }

            //Set Previous Data on Postbacks
            SetPreviousDataInf();
        }
        private void AddNewRowToGridinf()
        {
            if (ViewState["CurrentTableInf"] != null)
            {
                DataTable dtCurrentTable = (DataTable)ViewState["CurrentTableInf"];
                DataRow   drCurrentRow   = null;

                if (dtCurrentTable.Rows.Count > 0)
                {
                    drCurrentRow            = dtCurrentTable.NewRow();
                    drCurrentRow["NumeroI"] = dtCurrentTable.Rows.Count + 1;

                    //add new row to DataTable
                    dtCurrentTable.Rows.Add(drCurrentRow);


                    for (int i = 0; i < dtCurrentTable.Rows.Count - 1; i++)
                    {
                        //extract the TextBox values

                        TextBox box1 = (TextBox)GridviewInf.Rows[i].Cells[1].FindControl("TxtInf");

                        dtCurrentTable.Rows[i]["Column1"] = box1.Text;
                    }

                    //Store the current data to ViewState for future reference
                    ViewState["CurrentTableInf"] = dtCurrentTable;


                    //Rebind the Grid with the current data to reflect changes
                    GridviewInf.DataSource = dtCurrentTable;
                    GridviewInf.DataBind();
                }
            }
            else
            {
                Response.Write("ViewState is null");
            }
            //Set Previous Data on Postbacks
            SetPreviousDataInf();
        }
        //Inferior
        private void SetInitialRowinf()
        {
            DataTable dt = new DataTable();
            DataRow   dr = null;

            dt.Columns.Add(new DataColumn("NumeroI", typeof(string)));
            dt.Columns.Add(new DataColumn("Column1", typeof(string)));//for TextBox value

            dr            = dt.NewRow();
            dr["NumeroI"] = 1;
            dr["Column1"] = string.Empty;

            dt.Rows.Add(dr);

            //Guardar un Viewstate para hacer referencia
            ViewState["CurrentTableInf"] = dt;

            //Bind the Gridview
            GridviewInf.DataSource = dt;
            GridviewInf.DataBind();
        }