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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:08:14+00:00 2026-05-18T00:08:14+00:00

I am using an ASP.NET/C# DataList . <asp:DataList ID=EquipmentList RepeatColumns=5….. I have the following

  • 0

I am using an ASP.NET/C# DataList.

 <asp:DataList ID="EquipmentList" RepeatColumns="5".....  

I have the following line inside the <ItemTemplate> tag:

 <a href=""`><%# {I want to put something here but dont know how} %> </a>  

In my code behind I have a NameValueCollection variable that contains all strings:

 NameValueCollection myListofStrings = //calling a method here that populates myListofStrings   
this.EquipmentList.DataSource =  myListofStrings;  
this.EquipmentList.DataBind();

Please can someone tell me how to bind this NameValueCollection variable to my DataList tag in the markup? Also additional knowledge on how to bind a DataList to a DataSet, sqldatareader, IList<> would be helpful.

Thank you all. but for now what do I write inside the tag if lets say I have to bind to a 1NameValueCollection1 variable like in my case above. It has no properties or columns so I cannot write anything like Eval("propertyname") which is the answer that most here gave me. It is just like I am binding it to an array of strings.

So what do I write now?

  • 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-18T00:08:15+00:00Added an answer on May 18, 2026 at 12:08 am

    Please can someone tell me how to bind
    this NameValueCollection variable to
    my datalist tag in the markup? Also
    additional knowledge on how to bind a
    datalist to a dataset, sqldatareader,
    IList<> would be helpful. Thannks

    I declare my List<ComplexObject> in my codebehind (say … in a method attached to an OnClick) and then I will databind it like so:

    private void DoDataGetAndBind() {
      List<ComplexObject> complexObjects = _dataAccessLayer.GetComplexObjectsMethod(parameter1, parameter2, sortParameter);
      datalist1.DataSource = complexObjects;
      datalist1.DataBind();
    }
    

    Now please understand how simplified my code is, I didn’t put any error checks (like, if the database dropped or you returned no results) and I didn’t define the parameters or the ComplexObject (because I presume you understand how those things work).

    In the .aspx of the page, I would then define inside the ItemTemplate of the DataList control fields where I <%# Eval('ComplexObjectFieldOneName') %> or <%# Eval('ComplexObjectFieldTwoName') %> (etc).

    So given a

    public class ComplexObject {
      public string MyFirstField {get;set;}
      public string MySecondField {get;set;}
    }
    

    I would define the fields in the .aspx as <%# Eval('MyFirstField') %> and <%# Eval('MySecondField') %>

    Ok, that was rather long winded, so I hope it really did help.


    Another point: You can also use ObjectDataSources (or the derived classes like SqlDataSource, etc) and do all the linking on the .aspx, assuming properly built object classes. Something to consider.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i doing asp.net and using vb.net. I have a datalist control which inside it
In my asp.net I am using Datalist in that I want to limit row
using ASP.NET MVC 2 I have a navigation menu inside my Master Page. In
Does anyone know how to set the RepeatColumns property of an ASP.Net Datalist using
Using asp.net mvc 2 c#. I have a dynamic form. I want to get
I am using a databound DataList in ASP.NET C# to create a tag cloud.
Using ASP.Net MVC on my Site.Master I have: <head runat=server> <title><asp:ContentPlaceHolder ID=TitleContent runat=server />
Using asp.net 3.5 Gridview control, visual studio 2008. I have played with all the
Using ASP.NET MVC 2.0, I have an actionlink that is used for comments on
Using ASP.Net, I have a server control for which i would like to add

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.