using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace AjaxGrid
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "AddOne")
            {
                GridViewRow row = (GridViewRow)((Button)e.CommandSource).Parent.Parent;
                TextBox tbAmount = (TextBox)row.FindControl("tbAmount");
                Decimal amount = Decimal.Parse(tbAmount.Text);
                tbAmount.Text = Convert.ToString(amount + 1);
                ConfigureAjax(row);
            }
        }

        protected void ConfigureAjax(GridViewRow row)
        {
            Button btn = (Button)row.FindControl("btnAdd");
            TextBox tbAmount = (TextBox)row.FindControl("tbAmount");
            if ((btn != null) && (tbAmount != null))
                RadAjaxManager1.AjaxSettings.AddAjaxSetting(btn, tbAmount, AjaxLoadingPanel1);
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
                ConfigureAjax(e.Row);            
        }
    }
}
