My page contains two elements. A dropdown and a gridview
1) When the page is loaded the dropdown will be populated with some values.
2) I need to select a value from the dropdown.
3) Based on the value the gridview gets populated.
Issue : I have values like 10" valve , laptop , stationary pen, 12"valve etc
When I select laptop from the dropdown, the gridview gets populated with the details of the item.But when I select 10" valve , nothing is getting populated.
I found this issue for all items that contains " in it.
alch3mist291
0 Points
33 Posts
Dropdown and Gridview issue
Nov 13, 2012 07:48 AM|LINK
Hi,
My page contains two elements. A dropdown and a gridview
1) When the page is loaded the dropdown will be populated with some values.
2) I need to select a value from the dropdown.
3) Based on the value the gridview gets populated.
Issue : I have values like 10" valve , laptop , stationary pen, 12"valve etc
When I select laptop from the dropdown, the gridview gets populated with the details of the item.But when I select 10" valve , nothing is getting populated.
I found this issue for all items that contains " in it.
Can anyone please help me on this.
Thanks
oned_gk
All-Star
31766 Points
6492 Posts
Re: Dropdown and Gridview issue
Nov 13, 2012 08:04 AM|LINK
Use sql select command to replace " with a code to store ddl values, also use replace in WHERE condition gridview
Select REPLACE([Computertype],'"','xxx') as ddlvalue
alch3mist291
0 Points
33 Posts
Re: Dropdown and Gridview issue
Nov 13, 2012 08:05 AM|LINK
I am using a dropdown value as input value for gridview.
So how can I modify there ???
alch3mist291
0 Points
33 Posts
Re: Dropdown and Gridview issue
Nov 13, 2012 08:10 AM|LINK
can you give me a sample code
Madhu1234
Participant
1380 Points
287 Posts
Re: Dropdown and Gridview issue
Nov 13, 2012 10:27 PM|LINK
Check this links...
http://forums.asp.net/t/1527956.aspx/1?Display+gridview+based+on+drop+down+list+selection
http://forums.asp.net/t/1069559.aspx
Madhu1234
Participant
1380 Points
287 Posts
Re: Dropdown and Gridview issue
Nov 13, 2012 10:42 PM|LINK
Your SQL Datasource for Gridview should be something like this..
<asp:SqlDataSource ID="SqlDataSource1" SelectCommand="SELECT [EmployeeID], [FirstName], [LastName] FROM [Employees]WHERE ([EmployeeID] = @EmployeeID)"
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="EmployeeID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
oned_gk
All-Star
31766 Points
6492 Posts
Re: Dropdown and Gridview issue
Nov 13, 2012 11:22 PM|LINK
To simplify, use like this
Name Kode
Laptop Laptop
10" valve 10valve
stationary pen statpen
or
Name Kode
Laptop 00001
10" valve 00002
stationary pen 00003
use name as ddl text and kode as ddl value, use selectedvalue to filter the gridview
alch3mist291
0 Points
33 Posts
Re: Dropdown and Gridview issue
Nov 14, 2012 09:50 AM|LINK
I am getting all those values to the ddl from db via query.
I will post more details with screenshots soon.
(Is there any way to set different values for Name and code for a dropdown that got the values from db)
alch3mist291
0 Points
33 Posts
Re: Dropdown and Gridview issue
Nov 14, 2012 09:59 AM|LINK
Sorry for the confusion....but this is the situation.
During page load, my dropdown gets populated from DB.
Sample Values : 10" Valve , Pen drive , 14" laptop, 25" pipe etc
If I select Pen Drive, the gridview gets populated correctly. But if I select 10" Valve,the gridview is not getting populated.
I understood that it is due to "
( Will post screenshots asap )
fayaz_3e
Star
9332 Points
1744 Posts
Re: Dropdown and Gridview issue
Nov 14, 2012 10:21 AM|LINK
How are you building the query to fetch data in gridview? and what is the value stored in the table?