Friday, 20 April 2012
Add Data in Grid View by using footer Template
02:51
1 comment
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();
}
}
Subscribe to:
Posts (Atom)