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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:52:59+00:00 2026-05-17T00:52:59+00:00

I had gridview which in load it will get data from database .And I

  • 0

I had gridview which in load it will get data from database .And I added option for user to filter this grid view by DDl I did my code and the grid get data when load but when I selected DDl it didnot get any data and I made break point I noticed that Gridview1.Databind() hadnot any action on grid.So please any one help me

protected void Page_Load(object sender, EventArgs e)
{
    DataTable DT = new DataTable();

              if (DDlCity.SelectedIndex<0)
        {
            using (SqlConnection con = Connection.GetConnection())
            {
                SqlCommand Com = new SqlCommand("GetDealers", con);
                Com.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter DA = new SqlDataAdapter(Com);
                DA.Fill(DT);
                GridView1.DataSource = DT;
                GridView1.DataBind();
            }

        }


    }

protected void DDlCity_SelectedIndexChanged(object sender, EventArgs e)
{
    DataTable DT = new DataTable();
    using (SqlConnection con = Connection.GetConnection())
    {
        SqlCommand Com = new SqlCommand("GetDealersByArea", con);
        Com.CommandType = CommandType.StoredProcedure;
        Com.Parameters.Add(Parameter.NewInt("@DEALERAREA_ID", DDlCity.SelectedValue));
        SqlDataAdapter DA = new SqlDataAdapter(Com);
        DA.Fill(DT);
        GridView1.DataSource = DT;
        GridView1.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-05-17T00:53:00+00:00Added an answer on May 17, 2026 at 12:53 am

    i suppose you got confused on what i said…no worries
    here is a working example of you give example code.

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGridFunction();
        }
    }
    
    private void BindGridFunction()
    {
        try
        {
            DataTable DT = new DataTable();
            using (SqlConnection con = Connection.GetConnection())
            {
                if(DDlCity.SelectedIndex <0)
                {
                    SqlCommand Com = new SqlCommand("GetDealers", con);
                    Com.CommandType = CommandType.StoredProcedure;
                }
                else
                {
                    SqlCommand Com = new SqlCommand("GetDealersByArea", con);
                    Com.CommandType = CommandType.StoredProcedure;
                    Com.Parameters.Add(Parameter.NewInt("@DEALERAREA_ID", DDlCity.SelectedItem.Value));
                }
    
                SqlDataAdapter DA = new SqlDataAdapter(Com);
                DA.Fill(DT);
                GridView1.DataSource = DT;
                GridView1.DataBind();
            }
        }
        catch(Exception ex)
        {
            DT = null; // etc...etc.. clear objects created
        }
    
    }
    
    
    protected void DDlCity_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindGridFunction();
    }
    

    I hope you get what i was trying to say. You can change the code according to you need.

    Not tested yet but m sure will work.

    Note : i woud suggest to use “DDlCity.SelectedItem.Value” instead of ” DDlCity.SelectedValue”

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

Sidebar

Related Questions

I had gridview which retriev data from database and filter this gridview when I
I had gridview which get data from database according to two event .The first
I had grid view which bind sql data source and added field to update
I had gridview which retrieve Products from database by sqldatasource1 ,and my manager asked
I Had data gridview in widows application and I added button to export data
I had stored procedure which get data where Id=@id and the @id which pass
Had to download Command Line Tools from Apple to get make to work, but
I had Gridview bind sqldatasource and I had logins which see gridview and I
I had an ASP UpdatePanel to update a gridview which worked fine, now I
I had developed an album app in which I am using grid View. The

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.