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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:25:58+00:00 2026-06-10T10:25:58+00:00

I have a GridView : On Button_Click I want the first column of my

  • 0

enter image description here

I have a GridView:
On Button_Click
I want the first column of my GridView with the items of ListBox1 and 2nd column with the EDIT link and from 3rd column on wards I want the headers as the items of ListBox2.

So far I am able to achieve EDIT link in the 2nd column and from 3rd column on wards the headers of the GridView with ListBox2 items.

Now I want ListBox1 items as the first column of my GridView. I have attached an image with show what exactly I want and what I have achieved so far.

Kindly help me on. Thank you.

The .cs code I have designed is:

DataTable dt = new DataTable();
        DataRow rw = default(DataRow);
        for (int i = 0; i < ListBox3.Items.Count; i++)
        {  dt.Columns.Add(ListBox3.Items[i].ToString(),System.Type.GetType("System.String"));
        }

        for (int j = 0; j < count; j++)
        {
            rw = dt.NewRow();
            for (int i = 0; i < ListBox3.Items.Count; i++)
            {
                rw[ListBox3.Items[i].ToString()] = " ";
            }
            dt.Rows.Add(rw);
        }
        GridView2.DataSource = dt;
        GridView2.DataBind();

The asp code for GridView is :

<Columns>
            <asp:TemplateField HeaderText="Locations">
                <ItemTemplate>
                    <asp:Label ID="Lab1" runat="server"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowEditButton="True" />
            </Columns>
  • 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-10T10:26:00+00:00Added an answer on June 10, 2026 at 10:26 am

    First create a event of your gridview_RowDataBound
    and change value of your label

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
     if (e.Row.RowType == DataControlRowType.DataRow)
        {
    
          Label lbl1= ((Label)e.Row.FindControl("Lab1"));
          lbl1.text = ListBox1.items[e.Row.RowIndex].ToString();
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview from database and the issue is i want to print
I have a GridView which is databound, on button_click I want to read the
I have used checkbox column in gridview. I want to check status of that
I have a gridview and I have a button on it.I want, if the
I have a TemplateField column in a gridview with a button inside of it.
I have a button inside of a gridview's template field. Onclick i want to
want to have a Hyperlink-Button in a gridView in which I can display a
I have a GridView with 4 columns and I would like to edit one
Currently I'm working on gridview it's have textbox on submit click I want to
I have a GridView containing records from a table which can be deleted or

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.