아래 코드에서 데이터 테이블에 값과 다른 빈 데이터 테이블 Orderdbl
이 있고 3 개의 열을 추가하는 정적 메서드가 있습니다.데이터 테이블의 값을 확인하고 데이터 테이블에 값을 추가하려면
이제 내 목표는 locationid,productid,quantity
을 정적 방법으로 보냅니다.
productid
의 데이터 테이블에 dtGrid
이 있는지 확인하고 값이없는 경우 다른 데이터 테이블 Orderdbl
을 확인한 다음 값이없는 경우 데이터 테이블 Orderdbl
에 값을 추가하고 세션에 저장해야합니다. Pls이 날 도와 줘요. 여기
[WebMethod(EnableSession = true)]
public static void InsertData(string LocationID, string ProductID, string Quantity)
{
MastersClient objIndent = new MastersClient();
DataTable dtGrid = (DataTable)HttpContext.Current.Session["VSOrderForm"];
// DataSet ds = objIndent.CheckForExistingOrder(Int32.Parse(LocationID), ProductID);
var DataCheck = dtGrid.Select("ProductID = '" + ProductID + "'");
if (DataCheck.Length != 0)
{
// do something...
}
//if (ds != null && ds.Tables.Count > 0)
//{
//}
else
{
DataTable Orderdbl = new DataTable();
Orderdbl.Columns.Add("LocationID", typeof(string));
Orderdbl.Columns.Add("ProductID", typeof(string));
Orderdbl.Columns.Add("Quantity", typeof(string));
DataRow row = Orderdbl.NewRow();
//if (string.IsNullOrEmpty((string)Orderdbl.Rows[i][j].value))
if (Orderdbl == null)
{
row["LocationID"] = LocationID;
row["ProductID"] = ProductID;
Orderdbl.Rows.Add(row);
HttpContext.Current.Session["OrderForm"] = Orderdbl;
}
else
{
string FilterCond1 = "ProductID=" + ProductID;
DataRow[] newrow = Orderdbl.Select(FilterCond1);
if (newrow.Length > 0)
{
for (int i = 0; i < newrow.Length; i++)
{
if (newrow[i]["ProductID"].ToString() == ProductID)
{
// YOUR CODE HERE
}
}
}
else
{
row["LocationID"] = LocationID;
row["ProductID"] = ProductID;
Orderdbl.Rows.Add(row);
HttpContext.Current.Session["OrderForm"] = Orderdbl;
}
}
}
}
죄송합니다 친구를 추가 할 경우 dtGrid 테이블에 보면 want.First 것입니다. 여기에 아무도 코드를 작성하지 않습니다. 혹시 이상한 오류가 발생하거나 문제가있는 경우 사람들이 아이디어를 도울 것입니다. – Thangadurai
@ Thangadurai 내가 코드 pls을 작성했습니다 실수는 무엇입니까 – Developer
무엇이 오류입니까? – Mairaj