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

  • Home
  • SEARCH
  • 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 8316221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:18:45+00:00 2026-06-08T21:18:45+00:00

I have a GridView, <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False DataSourceID=SqlDataSource1> <Columns> <asp:BoundField DataField=LastName HeaderText=LastName SortExpression=LastName

  • 0

I have a GridView,

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="LastName" HeaderText="LastName" 
                    SortExpression="LastName" />
                <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                    SortExpression="FirstName" />
                <asp:BoundField DataField="ProgramName" HeaderText="ProgramName" 
                    SortExpression="ProgramName" />
            </Columns>
 </asp:GridView>

This is the ListBox method which I am using to refresh the GridView,

protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {        
        if (ListBox1.SelectedValue == "Computer Programmer")
        {
          DataSet test =  GetStudentByProgramID(1);
          if (test.Tables.Count > 0)
          {
              GridView1.Columns.Clear();
              GridView1.DataSource = test;
              GridView1.Attributes.Add("style", "table-layout:fixed");
              //ISBNColumn
              BoundField LastName = new BoundField();
              //LastName.DataField = test.Tables.r.ColumnName;
              LastName.HeaderText = "ISBN";
              LastName.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
              GridView1.Columns.Add(LastName);
              //CopyNumberColumn
              BoundField FirstName = new BoundField();
              //FirstName.DataField = myitems.Items.CopyNumberColumn.ColumnName;
              FirstName.HeaderText = "Copy Number";
              FirstName.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
              GridView1.Columns.Add(FirstName);
              GridView1.DataBind();
          }

        }
    }

But GridView does not get refreshed when I select the value from ListBox. Any mistake I am making here?
Also my listbox is getting filled like this,

DataSet ab = GetProgramList();
        ListBox1.Items.Clear();


        if (ab.Tables[0].Rows.Count > 0)
        {
        ListBox1.DataSource = ab;
        ListBox1.DataTextField ="ProgramName";
        ListBox1.DataValueField ="ProgramName";
        ListBox1.DataBind();
        }
  • 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-08T21:18:47+00:00Added an answer on June 8, 2026 at 9:18 pm

    make sure your listbox has

    AutoPostBack="True"

    <asp:ListBox id="ListBox1" 
                   Rows="4"
                   AutoPostBack="True" 
                   SelectionMode="Single"  
                   runat="server">
    
    if(!IsPostBack)
    {
            DataSet ab = GetProgramList();
            ListBox1.Items.Clear();
    
    
            if (ab.Tables[0].Rows.Count > 0)
            {
            ListBox1.DataSource = ab;
            ListBox1.DataTextField ="ProgramName";
            ListBox1.DataValueField ="ProgramName";
            ListBox1.DataBind();
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<asp:GridView ID=gridInboxMessage runat=server AutoGenerateColumns=False DataSourceID=LinqDataSource1> <Columns> <asp:BoundField DataField=Title HeaderText=title ReadOnly=True SortExpression=Title /> <asp:BoundField DataField=Body
I have a Gridview <asp:GridView ID=GridView1 runat=server Width=400px AutoGenerateColumns=false OnSelectedIndexChanged=GridView1_SelectedIndexChanged1> <Columns> <asp:TemplateField> <ItemTemplate> <asp:CheckBox
I have this code <asp:GridView ID=gvCentersList runat=server AutoGenerateColumns=False DataKeyNames=CenterID DataSourceID=SqlDataSource1 CssClass=gv-classic> <Columns> <asp:TemplateField HeaderText=>
I have a gridview with the alternatingRowStyle property set. <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False DataSourceID=SqlDataSource2
I have a GridView : <asp:GridView ID=GridView1 runat=server AllowPaging=True GridLines=None HorizontalAlign=Left AutoGenerateColumns=False DataSourceID=SqlDataSource1 onrowcommand=GridView1_RowCommand1>
I have the following aspx: <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False BorderStyle=None Font-Names=Verdana Font-Size=12px OnSelectedIndexChanged=GridView1_SelectedIndexChanged ShowHeader=False
I Have a and ASP.NET GridView which is set so <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False
Good afternoon, I have a gridview (resume of the gridview) <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False
ok the following is the code for the gridview: <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False BorderColor=#3399FF
I have defined a nested grid view in the following way. <asp:GridView ID=GridView1 runat=server

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.