Dear friends I have a issue in my codes. I am doing gridview insert ,update,delete events program.
I took one footer and displayed two textboxs and one Add button in the <EditItemTemplate>.
I have bound gridview.and displayed on the webform1.aspx properly.and on the RowCommand Event.
When I click on the add button for insert the values into my table from the Gridview’s rows. So my current page becomes blank. And everything becomes hide from the current page . why ???
My code are
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (!IsPostBack)
if (e.CommandName == "ADD")
{
Button Button1 = (Button)GridView1.FooterRow.FindControl("Button1");
TextBox txtfooterid = (TextBox)GridView1.FooterRow.FindControl("txtfooterid");
TextBox txtfootername = (TextBox)GridView1.FooterRow.FindControl("txtfootername");
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=True");
SqlCommand cmd = new SqlCommand("insert into tab1(id,name) values('"+txtfooterid.Text+"','"+txtfootername.Text+"')", con);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}

Anubhav ChaudharyPosted Jan 14, 2015, 12:44 AM
Buddy just tell me one thing you are using insert command and trying to get data from that, insert command will insert data into DB not fetch data from DB, use select command to fetch data and then bind it to DataTable and from DataTable to GridView.
Saineshwar BageriPosted Jan 13, 2015, 11:22 PM
http://dotnet-sai.blogspot.in/p/all-gridview-example.html
Mark as Answer if i had solved your problem