using System; using System.Data; using System.Configuration; 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; using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page { string connstr = "server=.;database=pubs;uid=sa;pwd="; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bind(); } } private void bind() { SqlConnection conn = new SqlConnection(connstr); conn.Open(); SqlDataAdapter da = new SqlDataAdapter("select * from Student", conn); DataSet ds = new DataSet(); da.Fill(ds); conn.Close(); this.FormView1.DataSource = ds.Tables[0]; this.FormView1.DataBind(); } protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e) { if (e.CommandName == "insert") { string s = FormView1.Row.FindControl("TextBox4").ToString(); Response.Write(s); } } }
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
{
string connstr = "server=.;database=pubs;uid=sa;pwd=";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}
} private void bind()
{
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from Student", conn);
DataSet ds = new DataSet();
da.Fill(ds);
conn.Close();
this.FormView1.DataSource = ds.Tables[0];
this.FormView1.DataBind();
} protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
{
if (e.CommandName == "insert")
{
string s = FormView1.Row.FindControl("TextBox4").ToString();
Response.Write(s);
}
}
}