have you enabled the autopostback ??
                                                                
<asp:dropdownlist id="ddlfilter" runat="server"
CssClass="InputBox" AutoPostBack="True">
                                                                        
<asp:ListItem Value="0">All Status</asp:ListItem>
                                                                        
<asp:ListItem Value="1">Approval</asp:ListItem>
                                                                        
<asp:ListItem Value="2">Ready</asp:ListItem>
                                                                        
<asp:ListItem Value="3">Cancel</asp:ListItem>
                                                                        
<asp:ListItem Value="4">STNK</asp:ListItem>
                                                                        
<asp:ListItem Value="5">Invoice</asp:ListItem>
                                                                        
<asp:ListItem Value="9">Ready Stock</asp:ListItem>
                                                                
</asp:dropdownlist></TD>


2009/7/2 Cerebrus <[email protected]>:
>
> Do you really see the Country names in the DDL using that code ?
>
> IMHO, without setting the DisplayValueField and DisplayTextField
> properties of the DropDownList, all you should see is a result of
> ToString() being called on each item within the IEnumerable
> datasource... in this case, it might be "DataRowView".
>
> On Jul 1, 1:12 pm, vickyk <[email protected]> wrote:
>> There is a table in a database having country names and their id.
>> I fetched the data from the table to a dropdownlist,which i did by
>> writing:
>>
>> public partial class _Default : System.Web.UI.Page
>> {
>>     protected void Page_Load(object sender, EventArgs e)
>>     {
>>         SqlConnection con = new SqlConnection("Persist Security
>> Info=False;Integrated Security=SSPI;server=CODENAME;database=try");
>>         SqlCommand com = new SqlCommand("Select CountryId,CountryName
>> from country", con);
>>         SqlDataAdapter da = new SqlDataAdapter(com);
>>         DataSet ds = new DataSet();
>>         da.Fill(ds);
>>         countryddl.DataSource = ds;
>>         countryddl.DataBind();
>>     }
>>
>> now i want to display the corresponding ID of the country when the
>> country is selected so i
>> wrote this and postback is ON.
>>
>> protected void countryddl_SelectedIndexChanged(object sender,
>> EventArgs e)
>>     {
>>         int sel_val = Convert.ToInt32(Convert.ToString
>> (countryddl.SelectedValue));
>>         Response.Write(sel_val);
>>
>> }
>>
>> still it always gives ID of the 1st country no matter what i choose.
>> how to solve this ??



-- 
Michael Butarbutar
+6281396102237 / +626176372947
ym : michaelb_zone
msn: michaelbzone

Reply via email to