Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Data Generation in Grid based upon user drop down selections.

Back to Forum: Tech Off
  • User profile image
    bhanu_smile​507

    HI All,

    I am an newbie to this technology. I had requirement kind of thing, like, I had 5 cascading drop downs, which I created by using ajax control tool kit drop-down extenders, and used web-service to update the cascading drop downs content.

    In the same form I need to create a grid, so based upon selection of the user, the grid should change dynamically, like I would like to have some examples kind of things, lets say, ( i am considering an sample user selection) I had Four cascading drop- downs, like 1) Vehicles, 2)Type of Vehicles 3)Category of Vechicles and Name 4) Year.

    And those can be sub-categorized to 1) Vehicles ------------ Two Wheelers, Four Wheelers

    2) Two Wheelers -------- Bikes, Bicycles

    3) Bikes --------------- Honda, Yamaha, Harley Davidson4) Year ---------------- Manufactured that particular year

    So, Here I have taken the case if user selects two wheelers, as I said earlier, those were cascading drop downs, and if the user selects only the first drop down "Vehicles" then we need to show all the info reg.the vehicles in a gridview control and if the user selects two dropdowns, lets say "Vehicles" and type as "Two Wheelers", then we need to show the information reg. that particular data, i.e. combination of records of that particular data in the grid view control and its goes on like that for remaining drop downs. And all these information is maintained in a single database table.

    And currently I am using Microsoft Sql Server 2008 R2, Visual Studio 2008, Using c#, ( i would be happy, if anyone gives me a code kind of thing, not mandatory, only if possible)...

    Regards,

    J.Bhanuchandra

  • User profile image
    ManipUni

    First put the database's data into a DataSet (Google for your database - it varies).
    Next add a DataGrid (or similar).
    Set the DataGrid's .DataSource to the DateSet
    Run DataGrid.DataBind()
    You're Done.

    This needs to be run each time the page refreshes(!). If you're doing the above and haven't seen the DataGrid populate you likely forgot to run DataBind after you refreshed the page last.

    Another word of warning, when you have the DataGrid population during the Page_Load event, make sure you have this right at the top:
    if (Page.IsPostBack)
     return;

    Otherwise your web-site will run like a dog. It will redraw the DataGrid constantly and will drive your DBA insane.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.