How can I add control clientID to the Request.Form collection while posting back
<p>Need help pretty soon on this.....</p>

<p>I have a Gridview in which the columns are mostly 'Itemtemplates' without any specific ID's assigned to them apart from the client ID given for the control inside them when rendered.</p>

<p>I am currently making changes to the existing page and few Client Id's for controls in the gridview appear in the Request.Form collection and few dont. 
 I need to add the client ID to the Request.Form collection and access it's value from there when posted back to the server.</p>

<p>How/when  do controls get added to the Request.Form collection? I am confused on this.
Any help will be highly appreciated.</p>

<p>Thanks</p>

<p>The code that adds dynamic columns to the grid:</p>

<pre><code>else if (Mode != ProductGridMode.Search)
    {
        grid.Columns.Add(CreateTemplateField(
            path + "ProductDetailHeader.ascx",
            path + "ProductDetailCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "CustomerPartNumberHeader.ascx",
            path + "CustomerPartNumberCell.ascx", "td-partnumber"));

        grid.Columns.Add(CreateTemplateField(
            path + "OrderQuantityHeader.ascx",
            path + "OrderQuantityCell.ascx", "td-qty"));

        if (Mode == ProductGridMode.OrderHistoryPayments
            || Mode == ProductGridMode.OrderHistoryPaymentsPrintView)
        {
            grid.Columns.Add(CreateTemplateField(
                path + "AvailableToShipHeader.ascx",
                path + "AvailableToShipCell.ascx"));
        }

        grid.Columns.Add(CreateTemplateField(
            path + "PriceHeader.ascx",
            path + "PriceCell.ascx", "td-price"));

        grid.Columns.Add(CreateTemplateField(
            path + "ExtendedPriceHeader.ascx",
            path + "ExtendedPriceCell.ascx", "td-ext-price"));

        if (Mode == ProductGridMode.OrderHistory || Mode == ProductGridMode.OrderHistoryPrintView
            || Mode == ProductGridMode.OrderHistoryPayments || Mode == ProductGridMode.OrderHistoryPaymentsPrintView)
        {
            grid.Columns.Add(CreateTemplateField(
                path + "InvoiceHeader.ascx",
                path + "InvoiceCell.ascx"));

            grid.EmptyDataTemplate = LoadTemplate(path + "EmptyDataTemplate.ascx");
        }
    }
    else
    {

        grid.Columns.Add(CreateTemplateField(
            path + "ImageHeader.ascx",
            path + "ImageCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "MouserPartNumberHeader.ascx",
            path + "MouserPartNumberCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "MfrPartNumberHeader.ascx",
            path + "MfrPartNumberCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "ManufacturerHeader.ascx",
            path + "ManufacturerCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "DescriptionHeader.ascx",
            path + "DescriptionCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "DocumentHeader.ascx",
            path + "DocumentCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "AvailabilityHeader.ascx",
            path + "AvailabilityCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "PricingHeader.ascx",
            path + "PricingCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "QuantityHeader.ascx",
            path + "QuantityCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "OrderInfoHeader.ascx",
            path + "OrderInfoCell.ascx"));

        grid.Columns.Add(CreateTemplateField(
            path + "RoHSHeader.ascx",
            path + "RoHSCell.ascx"));

        // Don't include Select column in count
        Search_TemplateColumnCount = grid.Columns.Count - CellOffset;

        // Due to their nature, the dynamic columns must be created as late as possible which is
        // right before databinding instead of here.
    }
</code></pre>

<p>aspx for the user control used in one of the item templates (the one i care about)</p>

<pre><code>    &lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="MfrPartNumberCell.ascx.cs"
    Inherits="Controls_ProductGridTemplates_Search_MfgPartNumberCell"        WhitespaceCleaning="Clean" %&gt;
&lt;div style="text-align: left;"&gt;
        &lt;%--&lt;asp:Literal ID="litMfrPartNumber" runat="server" Text='&lt;%# Bind("MfrPartNumber") %&gt;' /&gt;&lt;br /&gt;--%&gt;
        &lt;asp:HyperLink ID="MfrPartNumberLink" runat="server" Text='&lt;%# Bind("MfrPartNumber") %&gt;'
        OnDataBinding="MfrPartNumberLink_DataBinding" /&gt;&lt;br /&gt;
    &lt;br /&gt;
    &lt;asp:HyperLink ID="lnkCrossReference" runat="server" CssClass="highlight" Style="color: #FF6600"
        Target="_blank" OnDataBinding="lnkCrossReference_DataBinding" /&gt;
    &lt;div style="width: 100%; text-align: center;"&gt;
        &lt;asp:PlaceHolder ID="PHlifecycle" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Code behind for user control:</p>

<pre><code>    public partial class Controls_ProductGridTemplates_Search_MfgPartNumberCell : System.Web.UI.UserControl
{
    protected void Page_PreRender(object sender, EventArgs e)
    {
        lnkCrossReference.Visible = (lnkCrossReference.NavigateUrl != string.Empty);
    }

    protected void MfrPartNumberLink_DataBinding(object sender, EventArgs e)
    {
        SearchResultItem searchItem = BusinessHelper.GetDataItem(this) as SearchResultItem;

        MfrPartNumberLink.NavigateUrl = BusinessHelper.BuildProductDetailUrl(searchItem);

        //life cycle
        if (searchItem.LifeCycle != "")
        {
            if (!(searchItem.XXXX== false &amp;&amp; searchItem.LifeCycle.ToLower().Trim() == "new at mouser"))
            {
                string lifecycleInfo = Mouser.BOM.ExcelHelper.ProductRules.BuildLifecycleText(searchItem.LifeCycle);
                if (lifecycleInfo != "")
                    PHlifecycle.Controls.Add(new LiteralControl(lifecycleInfo + "&lt;br/&gt;&lt;br/&gt;"));
            }
        }

    }

    protected void lnkCrossReference_DataBinding(object sender, EventArgs e)
    {
        SearchResultItem searchItem = BusinessHelper.GetDataItem(this) as SearchResultItem;

        if (!string.IsNullOrEmpty(searchItem.CrossReference))
        {
            StringBuilder crossRefUrlBuilder = new StringBuilder();
            crossRefUrlBuilder.Append("~/Search/CrossPopUp.aspx?xpn=");
            crossRefUrlBuilder.Append(HttpUtility.UrlEncode(searchItem.MfrPartNumber));
            crossRefUrlBuilder.Append("&amp;criteria=");
            crossRefUrlBuilder.Append(HttpUtility.UrlEncode(searchItem.CrossReference));

            lnkCrossReference.NavigateUrl = crossRefUrlBuilder.ToString();
            lnkCrossReference.Attributes.Add("onclick",
                "javascript:window.open('" + ResolveUrl(lnkCrossReference.NavigateUrl)
                + "','CatalogPage', 'height=300,width=400,toolbars=no,menubar=no,location=no');return false;");
            lnkCrossReference.Text = String.Format(Resources.MyCXXXX.lnkCrossReference, searchItem.CrossReference);
        }
    }
}
</code></pre>
