create gridview rows programmatically

Posted on 2006-05-17
Last Modified: 2008-01-09
I want to add data to a gridview programmatically by looping through a collection. Something like:

        List<MyClass> object_list = bdb.GetSoundexNames(txtFirstName.Text, txtMiddleName.Text, txtLastName.Text);
        foreach (MyClass obj in object_list)
             // I want to create the columns Firstname, middlename and lastname

Can someone please help me with the syntax?

Should I create the columns programatically too? Or should I just add some html code in the aspx page?
Question by:IUAATech
    LVL 33

    Accepted Solution

    I'd highly recommend not doing this...It just is going to make your life much more difficult!

    If you can do it in the HTML, do it, if you don't think you can do it, let me know why not and I'll see what I can't tell you so you can do it.

    Author Comment

    I think I can do it in the HTML. Will let u know if I have any trouble.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now