Friday 20 April 2012

Add Data in Grid View by using footer Template


  Add Data in  Grid View by using footer Template

 A.  Frist  Gridview's property
    1.Showfooter=true;

B.  Go to Gridview's Smarttag and  EditColume-
     Select field   srno then  after click - Convert this field into a template field
C. Gridview's Smarttag  -Edit Template

          Grid View Tasks- select footer template
          after selected  any controle drag in thish tempalate
        ending tempalate editing
     

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

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

    }

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
              TextBox t1 = (TextBox)GridView1.FooterRow.FindControl("txtsrno");
              TextBox t2 = (TextBox)GridView1.FooterRow.FindControl("txtname");
             TextBox t3 = (TextBox)GridView1.FooterRow.FindControl("txtfather");

                   SqlDataSource1.InsertParameters["SrNo"].DefaultValue = t1.Text;
                   SqlDataSource1.InsertParameters["Name"].DefaultValue = t2.Text;
                   SqlDataSource1.InsertParameters["Father"].DefaultValue = t3.Text;
                   SqlDataSource1.Insert();
                   GridView1.DataBind();
    }
}






                 

1 comments:

  1. I have been searching for a useful post like this on salesforce course details, it is highly helpful for me and I have a great experience with this Salesforce Training who are providing certification and job assistance. Salesforce admin training in Gurgaon

    ReplyDelete