string query = string.Format("update Product set BalanceOnStock='{0}' where ProHead='{1}'", value.ToString(), ddlItem);
It's still not working please assist me for the same i am sending you the whole coding of the same page...
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 DailyComsumption : System.Web.UI.Page
{
SqlConnection cn;
SqlCommand cm;
int abc, dal, insert, showdata, baldata,updatebal,updateitem;
int item;
protected void Page_Load(object sender, EventArgs e)
{
string cs = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=true;User Instance=true";
cn = new SqlConnection(cs);
cn.Open();
}
protected void BtPrint_Click(object sender, EventArgs e)
{
Response.Redirect("Report.aspx");
}
protected void TxtWorkSelection_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (ListItem LBox4Item in ListBox4.Items)
{
ListBox5.Items.Add(LBox4Item);
int value = Convert.ToInt32( LBox4Item.ToString());
string query = string.Format("update Product set BalanceOnStock='{0}' where ProHead='{1}'", value.ToString(), DDLItem);
cm = new SqlCommand(query, cn);
cm.ExecuteNonQuery();
}
}
protected void DDLItem_SelectedIndexChanged(object sender, EventArgs e)
{
string q = "select QuantityforAssembly, BalanceOnStock from Product where ProHead ='" + DDLItem.SelectedItem.Text + "'";
cm = new SqlCommand(q, cn);
SqlDataReader r = cm.ExecuteReader();
while (r.Read())
{
ListBox1.Items.Add(r.GetString(0));
ListBox2.Items.Add(r[1].ToString());
}
foreach (ListItem LBoxItem in ListBox1.Items)
{
abc = Convert.ToInt32(LBoxItem.ToString());
insert = Convert.ToInt32(TxtWorkSelection.Text);
dal = Convert.ToInt32(abc * insert);
ListBox3.Items.Add(dal.ToString());
}
foreach (ListItem LBox3Item in ListBox3.Items)
{
foreach (ListItem LBox2Item in ListBox2.Items)
{
baldata = Convert.ToInt32(LBox2Item.ToString());
showdata = Convert.ToInt32(LBox3Item.ToString());
updatebal = baldata - showdata;
}
ListBox4.Items.Add(updatebal.ToString());
}
}
protected void BtGenReport_Click(object sender, EventArgs e)
{
}
protected void ListBox4_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void BtClear_Click(object sender, EventArgs e)
{
}
}
Please go to step wise step and give me the solution if possible
The last item value was updated and add to the database each row for example 4910,4910,4910,4910,4910,4910,4910,4910,4910,4910,4910 till statement of for each get not get false.