Link to home
Start Free TrialLog in
Avatar of ramziabk
ramziabk

asked on

Grid View and Drop down list in VB.NET

I created a VB.net Form with Drop down list and Grid View.

Once the Form Loads, I need the user to select the ID from the Drop down list. Based on the selection, The grid view will show ONLY the details related to the select ID.

How to achieve that?
Thanks
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ramziabk
ramziabk

ASKER

Apologizes for the mistake.I'm using ASP.NET.
Thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dear Code Cruiser,
I added your proposed code after editing it. I've noticed that the code in the selectedindexchanged is not being executed!!!!!

I've added a msgbox inside selectedindexchanged and when I run the project, I can view the drop down box. I can select an item in it but I'm not recieveing any msg!!!! and definitly the gridview is not changing!!
Set the AutoPostBack of the dropdownlist to true.
It is not working.
Is it possible the you send me the complete project. I'll change the datasource.

My database is MS SQL database.

Thanks
No I can't send the complete project as I dont have it. Show me your aspx and vb files.
Attached both files for your reference.

Thanks
Default.aspx
Default.aspx.vb
Why do you have

GridView1.Visible = False

at the top of your VB code?
because once I open the form, I need to see the dropdown list only. after selection, the grid view will show.
You are setting the visibility to false not true.
That is true. Visibilty of the Grid view is false when I load the form. Once I select the value from the drop down list, I'm setting the visibility to True!
   Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        GridView1.Visible = False

>Once I select the value from the drop down list, I'm setting the visibility to True!

YOU ARE NOT.
Appologises. It is my fault.
But anyway, I removed the  GridView1.Visible = False.

Now the DropDown list is not showing any value as if there is something wrong in the connect string!!!

Do you think the connection string is correct? Does it work if you hard code the connection string in?
The connection string is correct and it is already hardcoded.
>Now the DropDown list is not showing any value as if there is something wrong in the connect string!!!

How did you guess that then? Did you get any error?
Since I'm not a developer, more details was needed. But I thank CodeCrusier anyway.