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 6902647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:49:27+00:00 2026-05-27T07:49:27+00:00

Need help pretty soon on this….. I have a Gridview in which the columns

  • 0

Need help pretty soon on this…..

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.

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.

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

Thanks

The code that adds dynamic columns to the grid:

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.
    }

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

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

Code behind for user control:

    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 && searchItem.LifeCycle.ToLower().Trim() == "new at mouser"))
            {
                string lifecycleInfo = Mouser.BOM.ExcelHelper.ProductRules.BuildLifecycleText(searchItem.LifeCycle);
                if (lifecycleInfo != "")
                    PHlifecycle.Controls.Add(new LiteralControl(lifecycleInfo + "<br/><br/>"));
            }
        }

    }

    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("&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);
        }
    }
}
  • 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-05-27T07:49:28+00:00Added an answer on May 27, 2026 at 7:49 am

    Any HTML input control within a HTML form will be included in the Request.Form collection. These values are contained with the HTTP header of the POST operation.

    HTTP Headers for Dummies

    Edit: Added code

    default.aspx

    <%@ Page Title="Home Page" Trace="true" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind="Default.aspx.cs" Inherits="SO8362448._Default" %>
    
    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <asp:GridView ID="gridView" runat="server" OnRowDataBound="gridView_rowDataBound" AutoGenerateColumns="false">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Literal runat="server" Text='<%# Eval("Name") %>' />
                        <asp:LinkButton id="hyperLink" runat="server" Text="Click Me" />
                        <asp:HiddenField ID="hiddenField" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView> </asp:Content>
    

    default.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace SO8362448
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                gridView.DataSource = new List<Person>
                {
                    new Person {Name = "Steve", Age = 21},
                    new Person {Name = "Cindy", Age = 34}
                };
                gridView.DataBind();
            }
    
            protected void gridView_rowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    LinkButton lb = e.Row.FindControl("hyperLink") as LinkButton;
                    if (lb != null)
                    {
                        HiddenField hf = e.Row.FindControl("hiddenField") as HiddenField;
                        if (hf != null)
                        {
                            hf.Value = lb.Text;
                        }
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I need help. I'm usually pretty good at SQL queries but this one
I need help. I have to do a very specific SQL Statement and I
Need help figuring this out. Have a product model: class Product :name :short_description :price
I need some help with this code. I am pretty sure the code is
I need some with help with PowerShell, please. It should be pretty easy: I
Need help writing a script downloads data from google insight using c# this is
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,
I need help with some rewrite rule Pretty much all my pages look like
I have a coding/maths problem that I need help translating into C#. It's 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.