0
我有一個從linq到sql查詢的gridview,我想用文本中的值更新此gridview的列框。在這個GridView是一些產品的折扣,我選擇了一些產品在LINQ到SQL查詢,然後我想改變他們的折扣。 Iam在文本框中插入新的折扣,按下按鈕「保存更改」,我想更新新產品的折扣。我的代碼:如何更新gridview中的一列與文本框的值c#asp.net linq to sql
protected void btnDisplay_Click(object sender, ImageClickEventArgs e)
{
OrdersDataContext contex = new OrdersDataContext();
var query2 = from d in contex.Discounts
join r in contex.Registrations on d.id_reg equals r.id
join pr in contex.Products on d.id_prod equals pr.id
join p in contex.pTs on pr.pId equals p.id
join dim in contex.dimTs on p.dimId equals dim.id
join t in contex.typeTs on dim.typeId equals t.id
join c in contex.codeTs on t.codeId equals c.id
where (r.fullname == txtCompName.Text && r.password == txtpass.Text && c.code == TextBox1.Text && t.type == TextBox2.Text && dim.dimension == TextBox3.Text)
select new
{
CompanyName = r.fullname,
Article = pr.article,
Description = pr.description,
Price = pr.price,
Discount = d.discounts
};
GridViewDiscounts.DataSource = query2.ToList();
GridViewDiscounts.DataBind();
}
protected void btnSave_Click(object sender, ImageClickEventArgs e)
{
OrdersDataContext contex = new OrdersDataContext();
if (GridViewDiscounts.Rows.Count != 0)
{
foreach (GridViewRow row in GridViewDiscounts.Rows)
{
//here is my problem!!!!
}
}
ClearDetails();
string Msg = "<script>alert('Data updated successfully!');</script>";
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", Msg, false);
}
}
}
誰能幫助我,請???