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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:40:28+00:00 2026-06-17T09:40:28+00:00

I have data returning to a Gridview in .net from a dynamic database and

  • 0

I have data returning to a Gridview in .net from a dynamic database and one of the fields has a long list of semi-colon delimited values. I was able to display this data using line breaks in place of semi-colons however as there is potentially up to 20 values in this field I’m sure there’s a better way of displaying this.

I used the following code to create and amend a template field:

<asp:TemplateField HeaderText="Amalgamation"
                    SortExpression="Amalgamation">
                    <ItemTemplate>
                        <%# Eval("Amalgamation").ToString().Replace(";", "<br />")%>
                    </ItemTemplate>
                </asp:TemplateField>

An example of the data which will populate this field is: 100001;100002;600001;600006.

Update: Ive tried this but had no joy. In the html:

<%#PopulateArray((string)(Eval("Amalgamation")))%>
<asp:DropDownList ID="ddlStrings" AutoPostBack="true" runat="server"></asp:DropDownList>

Then this function in the code behind:

public object PopulateArray(string s) 
{ 
string[] sArray = s.Split(';'); 
DropDownList ddl = new DropDownList(); 
ddl = (DropDownList)this.Page.FindControl("ddlStrings"); 
ddl.DataSource = sArray; 
ddl.DataBind();
return sArray;
}

I get a NullReferenceException on the line: ddl.DataSource = sArray

  • 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-17T09:40:29+00:00Added an answer on June 17, 2026 at 9:40 am

    OK I’ve got the bottom of it. I was referencing the ID for the Dropdown instead of referencing each row instance of it. I put the code in the row created event of the gridview using the parameter:

    onrowcreated="ArrayDataView_RowCreated"
    

    I split the result using the semi-colon delimiter every time a row was created in the table. I also cast each result using the object class (“MyData”) I was using for the database. I then had to filter out the header and footer data rows of the gridview using an “if” statement. Here is the row created code in the code behind:

        protected void ArrayDataView_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList ddl = (DropDownList)e.Row.FindControl("ddlStrings");
                ddl.DataSource = (e.Row.DataItem as MyData).Amalgamation.Split(';');
            }       
        }
    }
    

    I dropped the eval function in the aspx page and the item template in the gridview was just reduced to housing the drop down:

    <ItemTemplate>
    <asp:DropDownList ID="ddlStrings" AutoPostBack="false" runat="server"></asp:DropDownList></ItemTemplate>
    

    Thanks to all who helped!

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

Sidebar

Related Questions

Hey guys. I'm building a simple blog and have my data returning from my
I have a report that is returning a one data field to a tablix
I have data from travel diaries which has been read in from a csv
I have a problem with returning data from ajax to caller function. When I'm
I have a chart I'm making in SSRS. My database is returning data like
(sorry for the english) I have a ASP .net webservice that get data from
I have a json object(say dobject) returning data from a json file Here is
I have the following data structure returning from a Yahoo API: cbfunc({ query: {
I have data being pulled in from various sources, each returning some form of
I have data access method that retrieves xml from database and returns back to

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.