Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use <a href="http://msdn.microsoft.com/en-us/library/xfhwa508%28v=vs.110%29.aspx" rel="nofollow">Dictionary</a> to pair each <code>prodID</code> with its corresponding <code>quantity</code>. Try this code:</p> <pre><code>protected void lbnConfirm_Click(object sender, EventArgs e) { Dictionary&lt;string, string&gt; tempList = new Dictionary&lt;string, string&gt;(); string quantity = "", prodID = ""; foreach (RepeaterItem item in Repeater1.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { Panel pnl = item.FindControl("pBody1") as Panel; GridView gv = pnl.FindControl("gvProduct") as GridView; foreach (GridViewRow gr in gv.Rows) { CheckBox cb = (CheckBox)gr.Cells[0].FindControl("cbCheckRow"); if (cb.Checked) { //Get the productID which set as DataKeyNames for selected row index prodID = gv.DataKeys[gr.RowIndex].Value.ToString(); var tbQuantity = gr.FindControl("tbQuantity") as TextBox; if (tbQuantity != null) { quantity = tbQuantity.Text; } tempList.Add(prodID, quantity); } } } } foreach (string key in tempList.Keys) { packagesNeeded = 1; unitQty = prodPackBLL.getUnitQtySPU(key); lblTest.Text += key + " " + tempList[key]; if (Convert.ToInt32(tempList[key]) &lt; (packagesNeeded * unitQty)) { //Pop up message Page.ClientScript.RegisterStartupScript(GetType(), "UserDialogScript", "alert(\"Insufficient storage\");", true); } } } </code></pre> <p>Based on your examples above, <code>tempList["1"]</code> will produce <code>"50"</code>, <code>tempList["2"]</code> will produce <code>"77"</code>, and <code>tempList["3"]</code> will produce <code>"90"</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload