Gridview Column Addition

Nov 15 2013 6:54 AM
Hi
I have grid as follows


Sr NoMin ValueMax Value
11500
2501700

I have two text box 1.Min Value 2.Max Value
and one add button
Now i want that first i enter min value as 1 and max as 500
when next time i enter the values Min value should automatically displayed as 501 as shown above
(i.e last Max Value + 1)
 how to do it im using following code to add values to grid

protected void BtnAdd_Click(object sender, EventArgs e)
    {
        DataTable obj = GetEmptyTable();
        foreach (GridViewRow gvRow in this.gv.Rows)
        {
            obj.Rows.Add(
                this.gv.DataKeys[gvRow.RowIndex].Values["MinValue"], 
                this.gv.DataKeys[gvRow.RowIndex].Values["MaxValue"], 
                gvRow.Cells[1].Text, 
                gvRow.Cells[2].Text);
        }
        obj.Rows.Add(
           this.TextBox1.Text,
             this.TextBox2.Text, );

        this.gv.DataSource = obj;
        this.gv.DataBind();
        
    }
and getemptyTable is

 private static DataTable GetEmptyTable()
    {
        var obj = new DataTable();
     
        obj.Columns.Add("MinValue");
        obj.Columns.Add("MaxValue");
    
        return obj;

    }


Please Help

Answers (4)