Sunday, 4 May 2014

Update datatable with gridview

No comments
 protected void btnupdate_Click(object sender, EventArgs e)
    {       
        Button bt1 = (Button)sender;
        GridViewRow gr1 = (GridViewRow)bt1.NamingContainer;
        DataTable dt1 = (DataTable)Session["data"];
        DataRow dr = dt1.Rows[gr1.RowIndex];

        Label productid = (Label)GridView1.Rows[gr1.RowIndex].FindControl("lblpid");
        Image img = (Image)GridView1.Rows[gr1.RowIndex].FindControl("Image1");
        Label pid = (Label)GridView1.Rows[gr1.RowIndex].FindControl("lblproduct_id");       
        if (tx.Text == "")
        {
            lblnoqty.Visible = true;
        }
        else
        {          
            dr["p_id"] = productid.Text;
            dr["Product_id"] = pid.Text;
            dr["Product_name"] = pname.Text;          
            GridView1.DataSource = dt1;          
            GridView1.DataBind();         
        }