Thursday, April 21, 2011

How to reset web form "CONTROL in ASP.NET" after save data

//call this function after completion of  insert query
 ClearInputs(Page.Controls);

 private void ClearInputs(ControlCollection ctrls)
    {

        foreach (Control ctrl in ctrls)
        {

            if (ctrl is TextBox)
            {
                ((TextBox)ctrl).Text = string.Empty;


            }
            else if (ctrl is DropDownList)
            {
                ((DropDownList)ctrl).ClearSelection();

            }

            ClearInputs(ctrl.Controls);

        }

    }

Tuesday, April 5, 2011

select gridview(template column) row index on button click

   GridViewRow row = ((Button)sender).Parent.Parent as GridViewRow;
    int index = row.RowIndex;