Click here to Skip to main content
15,904,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i had one Grid,in that grid one column is drop down like this
C#
<asp:TemplateField HeaderText="Type" ControlStyle-Width="55px">
                    <itemtemplate>
                        <asp:DropDownList ID="ddltype" runat="server"  SelectedText='<%# Eval("Taxfeetype").ToString().ToLower().Equals("tax") ? "Tax" : "Fee" %>'>
                            <asp:ListItem Value="fee">Fee
                            <asp:ListItem Value="tax">Tax
                        
                    </itemtemplate>

now i had one sql data table with the following columns
SQL
Taxfeetype nvarchar(5),
Decription nvarchar(50),
PercentorFlat nvarchar(20),
TaxFeeValue decimal(10,4)


now if i enter one record like this:
SQL
insert into Testtaxandfess values('Tax','Surpls Lines Tax','percent',3.0000)


automatically in dropdown tax should be selected...

similarly if i write record like this:
C#
insert into Testtaxandfess values('Fee','Inspection Fee','percent',100.0000)


fee should be defaultly selected....
please help
Posted
Updated 21-Nov-13 0:53am
v2
Comments
Thomas ktg 21-Nov-13 7:05am    
Where do you write the query and how do you relate the query with dropdownlist control?
spanner21 21-Nov-13 7:10am    
query is in sql...
we are realtinf through connection string and the remaining is through eval keyword
spanner21 21-Nov-13 7:11am    
query is in sql
ZurdoDev 21-Nov-13 7:47am    
Then you need to write code to select what you want. This is not clear at all.

1 solution

just replaced text property with value............


<asp:dropdownlist id="ddltype" runat="server" selectedvalue="<%# Eval(" taxfeetype").tostring().tolower().equals("tax")="" ?="" "tax"="" :="" "fee"="" %&gt;"="" xmlns:asp="#unknown">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900