Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:54:33+00:00 2026-06-15T02:54:33+00:00

I have a GridView that’s bound to a DropDownList. The GridView is updated by

  • 0

I have a GridView that’s bound to a DropDownList. The GridView is updated by a SQL query when the DropDownList’s index is changed. Values in the GridView’s Cells are turned into Labels and a TextBox is programmatically added. OnClick of a button the values of the Labels and TextBoxes are looped through and then submitted to a shopping cart.

I can’t get the value of the TextBoxes into my loop. FindControl can’t find the ID of the TextBox? I think it has to do with adding the TextBox programmatically?

Forgive my ignorance and coding approach… I’m only a year into ASP.

protected void Page_Load(object sender, EventArgs e) {
    NPBasePage _bp = (NPBasePage) Page;
    string myUserID = _bp.UserID;
    UserIDLabel.Text = myUserID;
    if (Page.IsPostBack) {} else {}
}

protected void RapidOrderEntry_RowDataBound(object sender, GridViewRowEventArgs e) {
    if (e.Row.RowType == DataControlRowType.DataRow) {
        foreach(TableCell c in e.Row.Cells) {
            TextBox l = new TextBox();
            l.ID = "QuantityTextBox";
            l.Text = "0";
            l.CssClass = "QuantityTextBox";
            Label b = new Label();
            b.ID = "PartNumberLabel";
            b.CssClass = "labelNone";
            Label x = new Label();
            x.Text = " ";
            x.CssClass = "null";
            b.Text = c.Text;
            if (c.Text == " ") {
                c.Controls.Add(x);
            } else {
                c.Controls.Add(l);
                c.Controls.Add(b);
            }
        }
    }
}

protected void AddTheseItemsToMyShoppingBagButton_Click(object sender, EventArgs e) {
    NPBasePage _bp = (NPBasePage) Page;
    NPOrder order = new NPOrder(_bp.UserID, _bp.SessionID);
    if (!order.Initialized) {
        order.CreateDefaultOrder(_bp.UserID, _bp.AccountID, _bp.SessionID);
    }
    for (int x = 0; x < RapidOrderEntry.Rows.Count; x++) {
        for (int y = 0; y < RapidOrderEntry.Rows[x].Cells.Count; y++) {
            NPOrderDetail newdet = order.AddPart((RapidOrderEntry.Rows[x].Cells[y].Text), Int32.Parse(((TextBox)RapidOrderEntry.Rows[x].Cells[y].FindControl("QuantityTextBox")).Text), _bp.CatalogCode, "", _bp.PriceList, 0, NPConnection.GetConfigDB("Commerce", "CalculationUoM"));
        }
    }
    Response.Redirect("/commerce/cart.aspx");
}

I am sure the problem lies in this and my loop:

Int32.Parse(((TextBox)RapidOrderEntry.Rows[x].Cells[y].FindControl("QuantityTextBox")).Text)

Error retuned is "Object reference not set to an instance of an object." If I manually set the integer to 1 like this:

NPOrderDetail newdet = order.AddPart((RapidOrderEntry.Rows[x].Cells[y].Text), 1, _bp.CatalogCode, "", _bp.PriceList, 0, NPConnection.GetConfigDB("Commerce", "CalculationUoM"));

It works like a charm. But the customer needs to be able to type in their own quantity.

EDIT

Here is my full code — hopefully that will help.

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="netpoint.api" %>
<%@ Import Namespace="netpoint.api.catalog" %>
<%@ Import Namespace="netpoint.api.commerce" %>
<%@ Import Namespace="netpoint.classes" %>
<%@ Import Namespace="netpoint.api.data" %>

<%@ Page language="c#" Inherits="netpoint.classes.NPBasePage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link rel="Shortcut Icon" href="/favicon.ico">
<title>Rapid Order Entry</title>
<link href="../../assets/common/themes/2011/css/partner.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../../assets/common/themes/2011/js/common.js"></script>

<style>
h2 {
    font-size: 15px;
    color: #2D210B;
    font-weight: bolder;
    margin-bottom: 0px;
    padding-bottom: 0px;
}
p {
    font-family: Arial, Verdana, Helvetica, sans-serif;
    font-size: 11px;
    line-height: 14px;
}
.red {
    background-color: #F66;
    color: #333;
}
.yellow {
    background-color: #FFDC78;
    color: #333;
}
.green {
    background-color: #B4DCB4;
    color: #333;
}
.null {
    background-color: #CCC;
}
#RapidOrderEntry th {
    width: 35px;
    height: 35px;
}
.color {
    font-weight: bold;
    width: 67px;
}
.labelNone {
    display: none;
}
.QuantityTextBox {
    width: 20px;
    height: 20px;
    text-align: center;
}
</style>



<script runat="server">
    
    protected void Page_Load(object sender, EventArgs e) {
        NPBasePage _bp = (NPBasePage) Page;
        string myUserID = _bp.UserID;
        UserIDLabel.Text = myUserID;
    
        if (Page.IsPostBack) {} 
        else {}
    }
    
    protected void RapidOrderEntry_RowCreated(object sender, GridViewRowEventArgs e) {
          if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int cellIndex = 0;
            foreach (TableCell c in e.Row.Cells)
            {
                TextBox l = new TextBox();
                l.ID = string.Format("QuantityTextBox_{0}_{1}", e.Row.RowIndex, cellIndex);
                l.Text = "0";
                l.CssClass = "QuantityTextBox";
                Label b = new Label();
                b.ID = string.Format("PartNumberLabel_{0}_{1}", e.Row.RowIndex, cellIndex);
                b.CssClass = "labelNone";
                Label x = new Label();
                x.Text = "&nbsp;";
                x.CssClass = "null";
                b.Text = c.Text;
                if (c.Text == "&nbsp;")
                {
                    c.Controls.Add(x);
                }
                else
                {
                    c.Controls.Add(l);
                    c.Controls.Add(b);
                }

                cellIndex++;
            }
        }
    }
    
    protected void AddTheseItemsToMyShoppingBagButton_Click(object sender, EventArgs e) {
        
        
        
        NPBasePage _bp = (NPBasePage) Page;
        NPOrder order = new NPOrder(_bp.UserID, _bp.SessionID);
        if (!order.Initialized) {
            order.CreateDefaultOrder(_bp.UserID, _bp.AccountID, _bp.SessionID);
        }
        for (int x = 0; x < RapidOrderEntry.Rows.Count; x++) {
            for (int y = 0; y < RapidOrderEntry.Rows[x].Cells.Count; y++) {
                
            TextBox tb = (TextBox)RapidOrderEntry.Rows[x].Cells[y].FindControl(string.Format("QuantityTextBox_{0}_{1}", x, y));
            int t = Int32.Parse((tb).Text);
            NPOrderDetail newdet = order.AddPart((RapidOrderEntry.Rows[x].Cells[y].Text), t, _bp.CatalogCode, "", _bp.PriceList, 0, NPConnection.GetConfigDB("Commerce", "CalculationUoM"));    
            }
        }
        Response.Redirect("/commerce/cart.aspx");
    }
    
    

    protected void PLMDropDownAlpha_SelectedIndexChanged(object sender, EventArgs e) {
        RapidOrderEntryDS.SelectParameters.Clear();
        PLMDropDownNum.SelectedIndex = 0;
        string PartNo = PLMDropDownAlpha.SelectedValue;
        RapidOrderEntryDS.SelectCommand = "SELECT Color, [1] [XS], [2] [S], [3] [M], [4] [L], [5] [XL], [6] [2XL], [7] [3XL], [8] [4XL], [9] [5XL], [10] [6XL], [11] [LT], [12] [XLT], [13] [2XLT], [14] [3XLT], [15] [4XLT], [16] [5XLT], [17] [6XLT], [18] [OSFM], [19] [ADJ] FROM (SELECT CASE SUBSTRING(PartsMaster.PartNo, CHARINDEX('-', PartsMaster.PartNo) + 1, CHARINDEX('-', PartsMaster.PartNo, CHARINDEX('-', PartsMaster.PartNo) + 1) - (CHARINDEX('-', PartsMaster.PartNo) + 1)) WHEN 'SDL' THEN 'Saddle' WHEN 'TBC' THEN 'Tobacco' WHEN 'APN' THEN 'Aspen' WHEN 'ASP' THEN 'Asphalt' WHEN 'BLK' THEN 'Black' WHEN 'FKH' THEN 'FldKhaki' WHEN 'GVL' THEN 'Gravel' WHEN 'GRV' THEN 'Gravel' WHEN 'MOS' THEN 'Moss' WHEN 'NVY' THEN 'Navy' WHEN 'SAW' THEN 'Sawdust' WHEN 'OS' THEN 'OSFM' WHEN 'BAR' THEN 'Barley' WHEN 'SGE' THEN 'Sage' WHEN 'STN' THEN 'Stone' WHEN 'MOC' THEN 'Mocha' WHEN 'DSK' THEN 'Dusk' WHEN 'ROS' THEN 'Rose' WHEN 'APL' THEN 'Apple' WHEN 'PER' THEN 'Persimon' WHEN 'SND' THEN 'Sand' WHEN 'MUS' THEN 'Mustard' WHEN 'GRN' THEN 'Green' WHEN 'BRN' THEN 'Brown' WHEN '0HD' THEN 'CamoHD' WHEN 'WHE' THEN 'Wheat' WHEN '0M4' THEN 'CamoMax4' WHEN 'OLV' THEN 'Olive' WHEN '0HG' THEN 'CamoHDG' WHEN 'CHR' THEN 'Charcoal' WHEN 'CAN' THEN 'Canyon' WHEN 'GRY' THEN 'Gray' WHEN 'RED' THEN 'Red' WHEN 'BLZ' THEN 'Blaze' WHEN 'MAR' THEN 'Maroon' WHEN 'WLD' THEN 'PPK' WHEN 'PPK' THEN 'OSFM' WHEN 'NGT' THEN 'Night' WHEN 'SLR' THEN 'Solar' WHEN 'WDF' THEN 'Wildfire' WHEN '0AP' THEN 'CamoAP' WHEN 'DOX' THEN 'DrkOxford' WHEN 'SUN' THEN 'Sunset' WHEN 'MDN' THEN 'Midnight' WHEN 'SHD' THEN 'Shadow' WHEN 'PTL' THEN 'Petal' WHEN 'LTN' THEN 'LtTan' WHEN 'CHC' THEN 'Chocolate' WHEN 'SMK' THEN 'Smoke' WHEN 'FTG' THEN 'Fatigue' WHEN 'CAC' THEN 'Cactus' WHEN 'ROP' THEN 'Rope' WHEN 'STL' THEN 'Steel' WHEN 'CLY' THEN 'Clay' WHEN 'KHA' THEN 'Khaki' WHEN 'CHA' THEN 'Charcoal' WHEN 'ERH' THEN 'Earth' WHEN 'MAZ' THEN 'Maize' WHEN 'PNK' THEN 'Pink' WHEN 'CSN' THEN 'Chestnut' WHEN 'FTG' THEN 'Fatigue' WHEN 'INK' THEN 'Ink' WHEN 'PTY' THEN 'Putty' WHEN 'BRK' THEN 'Bark' WHEN 'DWD' THEN 'Driftwood' WHEN 'EVG' THEN 'Evergreen' WHEN 'RWD' THEN 'Redwood' WHEN 'TWN' THEN 'Tawny' WHEN 'SLT' THEN 'Slate' WHEN 'TPE' THEN 'Taupe' WHEN 'TAN' THEN 'Tan' WHEN 'CHL' THEN 'Chili' WHEN 'ELM' THEN 'Elm' WHEN 'LAK' THEN 'Lake' WHEN 'DUN' THEN 'Dune' WHEN 'LDN' THEN 'Loden' WHEN 'STR' THEN 'Stream' WHEN 'SNS' THEN 'Sandston' WHEN 'DNM' THEN 'Denim' WHEN 'PEP' THEN 'Pepper' WHEN 'DBR' THEN 'DKBrown' WHEN 'MUD' THEN 'Mud' WHEN 'BRZ' THEN 'Bronze' WHEN 'GPH' THEN 'Graphite' WHEN 'WHT' THEN 'White' WHEN 'SPC' THEN 'Spice' WHEN 'DGR' THEN 'Dark Green' WHEN '0PA' THEN 'Pink Camo AP' WHEN 'PNE' THEN 'Pine' WHEN 'LGN' THEN 'Lagoon' WHEN 'OPA' THEN 'CamoPnkAP' WHEN '0AB' THEN 'CamoAPBlk' WHEN '0AE' THEN 'CamoAPEvg' WHEN 'CBL' THEN 'Colbalt' ELSE substring(PartsMaster.PartNo, 6, 3) END [Color], CASE WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'XS' THEN 1 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'S' THEN 2 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'M' THEN 3 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'L' THEN 4 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'XL' THEN 5 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '2XL' THEN 6 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '3L' THEN 7 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '4XL' THEN 8 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '5XL' THEN 9 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '6XL' THEN 10 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'LT' THEN 11 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'XLT' THEN 12 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '2XLT' THEN 13 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '3XLT' THEN 14 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '4XLT' THEN 15 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '5XLT' THEN 16 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '6XLT' THEN 17 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'OSFM' THEN 18 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'ADJ' THEN 19 ELSE '20' END [size], CASE WHEN PartsInventory.OnHand > 0 THEN PartsMaster.PartNo ELSE NULL END [stock_value] FROM PartsAttribute INNER JOIN PartsMaster ON PartsAttribute.PartNo = PartsMaster.PartNo LEFT OUTER JOIN PartsInventory ON PartsMaster.PartNo = PartsInventory.PartNo WHERE (LEN(PartsMaster.PartNo) > 9) AND (PartsMaster.ProductLinePartNo LIKE '" + PartNo + "') AND ((PartsAttribute.AttributeCode = N'size' OR PartsAttribute.AttributeCode = N'color')) AND PartsInventory.WarehouseCode IN ('01') AND (PartsAttribute.PartNo = PartsMaster.PartNo) AND (PartsMaster.PartNo = PartsInventory.PartNo) AND (PartsAttribute.PartNo = PartsInventory.PartNo) AND (PartsInventory.OnHand IS NOT NULL OR PartsAttribute.AttributeCode IS NOT NULL OR PartsMaster.PartNo IS NOT NULL OR PartsAttribute.Dimension1 IS NOT NULL)) AS source PIVOT (min(stock_value) FOR [Size] IN ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19])) AS pivoted";
        RapidOrderEntry.DataBind();
    }
    protected void PLMDropDownNum_SelectedIndexChanged(object sender, EventArgs e) {
        RapidOrderEntryDS.SelectParameters.Clear();
        PLMDropDownAlpha.SelectedIndex = 0;
        string PartNo = PLMDropDownNum.SelectedValue;
        RapidOrderEntryDS.SelectCommand = "SELECT Color, [1] [XS], [2] [S], [3] [M], [4] [L], [5] [XL], [6] [2XL], [7] [3XL], [8] [4XL], [9] [5XL], [10] [6XL], [11] [LT], [12] [XLT], [13] [2XLT], [14] [3XLT], [15] [4XLT], [16] [5XLT], [17] [6XLT], [18] [OSFM], [19] [ADJ] FROM (SELECT CASE SUBSTRING(PartsMaster.PartNo, CHARINDEX('-', PartsMaster.PartNo) + 1, CHARINDEX('-', PartsMaster.PartNo, CHARINDEX('-', PartsMaster.PartNo) + 1) - (CHARINDEX('-', PartsMaster.PartNo) + 1)) WHEN 'SDL' THEN 'Saddle' WHEN 'TBC' THEN 'Tobacco' WHEN 'APN' THEN 'Aspen' WHEN 'ASP' THEN 'Asphalt' WHEN 'BLK' THEN 'Black' WHEN 'FKH' THEN 'FldKhaki' WHEN 'GVL' THEN 'Gravel' WHEN 'GRV' THEN 'Gravel' WHEN 'MOS' THEN 'Moss' WHEN 'NVY' THEN 'Navy' WHEN 'SAW' THEN 'Sawdust' WHEN 'OS' THEN 'OSFM' WHEN 'BAR' THEN 'Barley' WHEN 'SGE' THEN 'Sage' WHEN 'STN' THEN 'Stone' WHEN 'MOC' THEN 'Mocha' WHEN 'DSK' THEN 'Dusk' WHEN 'ROS' THEN 'Rose' WHEN 'APL' THEN 'Apple' WHEN 'PER' THEN 'Persimon' WHEN 'SND' THEN 'Sand' WHEN 'MUS' THEN 'Mustard' WHEN 'GRN' THEN 'Green' WHEN 'BRN' THEN 'Brown' WHEN '0HD' THEN 'CamoHD' WHEN 'WHE' THEN 'Wheat' WHEN '0M4' THEN 'CamoMax4' WHEN 'OLV' THEN 'Olive' WHEN '0HG' THEN 'CamoHDG' WHEN 'CHR' THEN 'Charcoal' WHEN 'CAN' THEN 'Canyon' WHEN 'GRY' THEN 'Gray' WHEN 'RED' THEN 'Red' WHEN 'BLZ' THEN 'Blaze' WHEN 'MAR' THEN 'Maroon' WHEN 'WLD' THEN 'PPK' WHEN 'PPK' THEN 'OSFM' WHEN 'NGT' THEN 'Night' WHEN 'SLR' THEN 'Solar' WHEN 'WDF' THEN 'Wildfire' WHEN '0AP' THEN 'CamoAP' WHEN 'DOX' THEN 'DrkOxford' WHEN 'SUN' THEN 'Sunset' WHEN 'MDN' THEN 'Midnight' WHEN 'SHD' THEN 'Shadow' WHEN 'PTL' THEN 'Petal' WHEN 'LTN' THEN 'LtTan' WHEN 'CHC' THEN 'Chocolate' WHEN 'SMK' THEN 'Smoke' WHEN 'FTG' THEN 'Fatigue' WHEN 'CAC' THEN 'Cactus' WHEN 'ROP' THEN 'Rope' WHEN 'STL' THEN 'Steel' WHEN 'CLY' THEN 'Clay' WHEN 'KHA' THEN 'Khaki' WHEN 'CHA' THEN 'Charcoal' WHEN 'ERH' THEN 'Earth' WHEN 'MAZ' THEN 'Maize' WHEN 'PNK' THEN 'Pink' WHEN 'CSN' THEN 'Chestnut' WHEN 'FTG' THEN 'Fatigue' WHEN 'INK' THEN 'Ink' WHEN 'PTY' THEN 'Putty' WHEN 'BRK' THEN 'Bark' WHEN 'DWD' THEN 'Driftwood' WHEN 'EVG' THEN 'Evergreen' WHEN 'RWD' THEN 'Redwood' WHEN 'TWN' THEN 'Tawny' WHEN 'SLT' THEN 'Slate' WHEN 'TPE' THEN 'Taupe' WHEN 'TAN' THEN 'Tan' WHEN 'CHL' THEN 'Chili' WHEN 'ELM' THEN 'Elm' WHEN 'LAK' THEN 'Lake' WHEN 'DUN' THEN 'Dune' WHEN 'LDN' THEN 'Loden' WHEN 'STR' THEN 'Stream' WHEN 'SNS' THEN 'Sandston' WHEN 'DNM' THEN 'Denim' WHEN 'PEP' THEN 'Pepper' WHEN 'DBR' THEN 'DKBrown' WHEN 'MUD' THEN 'Mud' WHEN 'BRZ' THEN 'Bronze' WHEN 'GPH' THEN 'Graphite' WHEN 'WHT' THEN 'White' WHEN 'SPC' THEN 'Spice' WHEN 'DGR' THEN 'Dark Green' WHEN '0PA' THEN 'Pink Camo AP' WHEN 'PNE' THEN 'Pine' WHEN 'LGN' THEN 'Lagoon' WHEN 'OPA' THEN 'CamoPnkAP' WHEN '0AB' THEN 'CamoAPBlk' WHEN '0AE' THEN 'CamoAPEvg' WHEN 'CBL' THEN 'Colbalt' ELSE substring(PartsMaster.PartNo, 6, 3) END [Color], CASE WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'XS' THEN 1 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'S' THEN 2 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'M' THEN 3 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'L' THEN 4 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'XL' THEN 5 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '2XL' THEN 6 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '3L' THEN 7 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '4XL' THEN 8 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '5XL' THEN 9 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '6XL' THEN 10 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'LT' THEN 11 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'XLT' THEN 12 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '2XLT' THEN 13 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '3XLT' THEN 14 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '4XLT' THEN 15 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '5XLT' THEN 16 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = '6XLT' THEN 17 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'OSFM' THEN 18 WHEN PartsAttribute.AttributeCode = 'size' AND PartsAttribute.Dimension1 = 'ADJ' THEN 19 ELSE '20' END [size], CASE WHEN PartsInventory.OnHand > 0 THEN PartsMaster.PartNo ELSE NULL END [stock_value] FROM PartsAttribute INNER JOIN PartsMaster ON PartsAttribute.PartNo = PartsMaster.PartNo LEFT OUTER JOIN PartsInventory ON PartsMaster.PartNo = PartsInventory.PartNo WHERE (LEN(PartsMaster.PartNo) > 9) AND (PartsMaster.ProductLinePartNo LIKE '" + PartNo + "') AND ((PartsAttribute.AttributeCode = N'size' OR PartsAttribute.AttributeCode = N'color')) AND PartsInventory.WarehouseCode IN ('01') AND (PartsAttribute.PartNo = PartsMaster.PartNo) AND (PartsMaster.PartNo = PartsInventory.PartNo) AND (PartsAttribute.PartNo = PartsInventory.PartNo) AND (PartsInventory.OnHand IS NOT NULL OR PartsAttribute.AttributeCode IS NOT NULL OR PartsMaster.PartNo IS NOT NULL OR PartsAttribute.Dimension1 IS NOT NULL)) AS source PIVOT (min(stock_value) FOR [Size] IN ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19])) AS pivoted";
        RapidOrderEntry.DataBind();
    }
    protected void ViewShoppingBag_Click(object sender, EventArgs e) {
        Response.Redirect("/commerce/cart.aspx/");
    }
</script>



</head>
<body>
<form id="form1" runat="server">

<div align="center" style="font-family: Arial, Helvetica, sans-serif;"> 

<p>You can use these dropdown lists to quickly jump to all of one product's sizes and colors.</p>

      
        <asp:DropDownList ID="PLMDropDownAlpha" runat="server" AutoPostBack="True" 
            DataSourceID="ListByPLMDSAlpha" DataTextField="PartName" 
        DataValueField="PartNo" 
        onselectedindexchanged="PLMDropDownAlpha_SelectedIndexChanged" Width="225px" >
        </asp:DropDownList>
 
&nbsp;&nbsp;
       
        <asp:DropDownList ID="PLMDropDownNum" runat="server" AutoPostBack="True" 
            DataSourceID="ListByPLMDSNum" DataTextField="PartName" 
        DataValueField="PartNo" 
        onselectedindexchanged="PLMDropDownNum_SelectedIndexChanged" Width="225px" >
        </asp:DropDownList>
        
<asp:SqlDataSource ID="ListByPLMDSNum" runat="server" 
    ConnectionString="<%$ ConnectionStrings:connString %>" 
    SelectCommand="
        SELECT 'disabled' AS PartNo, ' Products by Part Number ' AS PartName, NULL AS PartCode
        UNION ALL
        SELECT PartNo, CASE
            WHEN PartNo LIKE '%-OD-%' THEN left(PartCode,4) + ' - '  + PartName + ' ' + 'Camo'
            WHEN PartNo LIKE '%-AP-%' THEN left(PartCode,4) + ' - ' + PartName + ' ' + 'Camo'
            WHEN PartNo LIKE '%-0HD-%' THEN left(PartCode,4) + ' - ' + PartName + ' ' + 'Camo'
            WHEN PartNo LIKE '%-0M4-%' THEN left(PartCode,4) + ' - ' + PartName + ' ' + 'Camo'
            ELSE left(PartCode,4) + ' - ' + PartName END PartName, PartCode
        FROM PartsMaster
        WHERE (ProductLineFlag = 'Y') AND (StaticThumbnail <> '')
        ORDER BY PartCode
    ">
</asp:SqlDataSource>

<asp:SqlDataSource ID="ListByPLMDSAlpha" runat="server" 
    ConnectionString="<%$ ConnectionStrings:connString %>" 
    SelectCommand="
        SELECT 'disabled' AS PartNo, ' Products by Part Name ' AS PartName
        UNION ALL
        SELECT PartNo, CASE 
            WHEN PartNO LIKE '%-OD-%' THEN PartName + ' ' + 'Camo'
            WHEN PartNO LIKE '%-AP-%' THEN PartName + ' ' + 'Camo'
            WHEN PartNO LIKE '%-0HD-%' THEN PartName + ' ' + 'Camo'
            WHEN PartNO LIKE '%-0M4-%' THEN PartName + ' ' + 'Camo'
            ELSE PartName END
        FROM PartsMaster
        WHERE (ProductLineFlag = 'Y') AND (StaticThumbnail <> '')
        ORDER BY PartName
    ">
</asp:SqlDataSource>
 
 
  <br />
  <br />
  <br />

  
  </asp:SqlDataSource>
  <asp:GridView ID="RapidOrderEntry" runat="server" datasourceid="RapidOrderEntryDS" OnRowCreated="RapidOrderEntry_RowCreated" autogeneratecolumns="False" style="width:790px;margin:0 auto;text-align:center;">
    <Columns>
        <asp:BoundField DataField="Color" HeaderText="" itemstyle-cssclass="color" />
        <asp:BoundField DataField="XS" HeaderText="XS" />
        <asp:BoundField DataField="S" HeaderText="S" />
        <asp:BoundField DataField="M" HeaderText="M" />
        <asp:BoundField DataField="L" HeaderText="L" />
        <asp:BoundField DataField="XL" HeaderText="XL" />
        <asp:BoundField DataField="2XL" HeaderText="2XL" />
        <asp:BoundField DataField="3XL" HeaderText="3XL" />
        <asp:BoundField DataField="4XL" HeaderText="4XL" />
        <asp:BoundField DataField="5XL" HeaderText="5XL" />
        <asp:BoundField DataField="6XL" HeaderText="6XL" />
        <asp:BoundField DataField="LT" HeaderText="LT" />
        <asp:BoundField DataField="XLT" HeaderText="XLT" />
        <asp:BoundField DataField="2XLT" HeaderText="2XLT" />
        <asp:BoundField DataField="3XLT" HeaderText="3XLT" />
        <asp:BoundField DataField="4XLT" HeaderText="4XLT" />
        <asp:BoundField DataField="5XLT" HeaderText="5XLT" />
        <asp:BoundField DataField="6XLT" HeaderText="6XLT" />
        <asp:BoundField DataField="OSFM" HeaderText="OSFM" />
        <asp:BoundField DataField="ADJ" HeaderText="ADJ" />
    </Columns>
    <EmptyDataTemplate>
      <div style="height:200px;" align="center"> 
            <h2 ID="EmptyDataTemplateOn" style="font-weight:normal;position:relative;top:80px;color:#999;display:none;">The Inventory Matrix for this item is currently unavailable due to insufficient stock information.<br />Item inventories are updated frequently.  Please try again later.</h2>
            <h2 ID="EmptyDataTemplateOff" style="font-weight:normal;position:relative;top:85px;color:#999;">Please choose an item.</h2>
      </div>
    </EmptyDataTemplate>
  </asp:GridView>
  <asp:SqlDataSource ID="RapidOrderEntryDS" runat="server" ConnectionString="<%$ ConnectionStrings:connString %>" />
        <SelectParameters>
                <asp:Parameter Name="PartNo" Type="String" />
            </SelectParameters>
  </asp:SqlDataSource>


    <br />
    <asp:Button ID="AddTheseItemsToMyShoppingBagButton" runat="server" Text="Add These Items to My Order" onclick="AddTheseItemsToMyShoppingBagButton_Click" />

<asp:Label ID="UserIDLabel" runat="server" Visible="false"></asp:Label>

</div>
</form>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:54:35+00:00Added an answer on June 15, 2026 at 2:54 am

    I think it’s a better idea to generate the TextBox fields or Labels
    using TemplateFields.

    EDIT

    You can create the controls in the RowCreated Event Handler, naming the controls with a unique name:

    protected void RapidOrderEntry_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int cellIndex = 0;
                foreach (TableCell c in e.Row.Cells)
                {
                    TextBox l = new TextBox();
                    l.ID = string.Format("QuantityTextBox_{0}_{1}", e.Row.RowIndex, cellIndex);
                    l.Text = "0";
                    l.CssClass = "QuantityTextBox";
                    Label b = new Label();
                    b.ID = string.Format("PartNumberLabel_{0}_{1}", e.Row.RowIndex, cellIndex);
                    b.CssClass = "labelNone";
                    Label x = new Label();
                    x.Text = "&nbsp;";
                    x.CssClass = "null";
                    b.Text = c.Text;
                    if (c.Text == "&nbsp;")
                    {
                        c.Controls.Add(x);
                    }
                    else
                    {
                        c.Controls.Add(l);
                        c.Controls.Add(b);
                    }
    
                    cellIndex++;
                }
            }
        }
    

    Then You can retrieve the control like this:

     protected void AddTheseItemsToMyShoppingBagButton_Click(object sender, EventArgs e)
     {
            for (int x = 0; x < RapidOrderEntry.Rows.Count; x++)
            {
                for (int y = 0; y < RapidOrderEntry.Rows[x].Cells.Count; y++)
                {
                    TextBox tb = (TextBox)RapidOrderEntry.Rows[x].Cells[y].FindControl(string.Format("QuantityTextBox_{0}_{1}", x, y));
                    int t = Int32.Parse((tb).Text);
                }
            }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview that is bound to the result from an nhibernate query.
I have a gridview that is SQL bound. In some of the columns there
I have a gridview that is bound to a datasource on a Windows Form
I have a gridview that is bound to a datasource (Windows Forms, VB.NET). One
I have a gridview that takes in values from a sortedlist. I want to
I have a GridView that is bound to an ObjectDataSource that is calling a
I have a GridView that gets it's data from the SQL database . I
I have a GridView that is bound with a dataset. I have my footer,
I have a gridview that contains around 16 ItemTemplate columns. The values in each
I have a gridview that I load from a linq query. MyGridData is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.