Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

i have datagrid where i bind the data in that.
i have one dropdown box. which like this :

XML
<asp:DropDownList ID="drpunit" runat="server" CssClass="input-short" Width="100px">
                        <asp:ListItem Value="0">--- Select  ---</asp:ListItem>
                        <asp:ListItem Value="1">Gram</asp:ListItem>
                        <asp:ListItem Value="2">KiloGram</asp:ListItem>
                    </asp:DropDownList>


now i store the store the value in database table.

when i bind datalist it display 1 , but i want to Gram insted of 1. me bound unit like this :
C#
<asp:BoundColumn HeaderText="Unit" DataField="Unit"></asp:BoundColumn>


How can i get text of dropdown insted of value.

Thank You to all....!!!
Posted

C#
dropdown1.SelectedText
will give "Gram"
and
C#
dropdown1.SelectedValue
will give 1

Updated answer.When retrieving it fromd database, in the select query set the value.
Something like this.
SQL
Select OrderId,(Case when unit=1,then 'Gram' when unit=2,then 'Kilogram' END ) as Unit from tbl
 
Share this answer
 
v3
Comments
Yatin chauhan 13-Aug-12 6:48am    
i know that but i can i retrieve Gram . i store 1 for gram and 2 for kilogram in database.
how can i get gram using boundcolumn in datagrid???
Santhosh Kumar Jayaraman 13-Aug-12 6:52am    
When retrieving it from database,set the text.Like
Select OrderId,(Case when unit=1,then Gram
when unit=2,then Kilogram END ) as Unit from tbl
Yatin chauhan 13-Aug-12 7:41am    
Hey Thank You So much i resolve that ..Thank You So Much Santosh...!!!
Santhosh Kumar Jayaraman 13-Aug-12 7:57am    
Welcome
try it like this.
<asp:listitem text="aas" value="0" 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