1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| 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
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BtnViewDetails_Click(object sender, EventArgs e)
{
ImageButton btnDetails = sender as ImageButton;
GridViewRow row = (GridViewRow)btnDetails.NamingContainer;
hidCategorieEditIndex.Value = Scrub(row.Cells[1].Text);
txtCategorie.Text = Scrub(row.Cells[2].Text);
this.updPnlCategorieDetail.Update();
this.mdlPopup.Show();
/*hidPCategorieEditIndex.Value = Scrub(row.Cells[1].Text);
this.sqldsCategorieDetails.SelectParameters.Clear();
this.sqldsCategorieDetails.SelectParameters.Add("idCategorie", Convert.ToString(this.gvCategories.DataKeys[row.RowIndex].Value));
this.dvCategorieDetail.DataSource = this.sqldsCategorieDetails;
this.dvCategorieDetail.DataBind();
this.updPnlCategorieDetail.Update();
this.mdlPopup.Show();*/
}
protected string Scrub(string text) { return text.Replace(" ", ""); }
protected void btnSave_Click(object sender, EventArgs e)
{
if (gvCategories.DataSourceID == sqldsCategorieDetails.ID)
{
SaveCategorie(sqldsCategorieDetails, Convert.ToInt16(hidCategorieEditIndex.Value), txtCategorie.Text);
}
this.gvCategories.DataBind();
this.updPnlCategorieDetail.Update();
this.mdlPopup.Hide();
}
private void SaveCategorie(SqlDataSource ds, Int16 id, string lblCategorie)
{
SqlCommand cmd = new SqlCommand(ds.UpdateCommand);
using (cmd)
{
using (cmd.Connection = new SqlConnection(ds.ConnectionString))
{
cmd.Connection.Open();
cmd.Parameters.AddWithValue("@idCategorie", id);
cmd.Parameters.AddWithValue("@Categorie", lblCategorie);
cmd.ExecuteNonQuery();
}
}
}
} |