开发者

unable to get dropdownlist selected index value?

ON ASPX PAGE ,I have one dropdownlist box and one text box. I have added two items in dropdownlist.

  1. Program

  2. Batchyear

On selected index changeded event, if I select l开发者_C百科istitem Program, I want the textbox to show

your program code is:134.

If I select listitem Batchyear, I want the textbox to show

your batch year is 2011.

I write code in cs page

 protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
 {
   if (ddl.SelectedIndex == 0)
   { 
     TextBox1.Text="your program code is:134" ;
   }

   if (ddl.SelectedIndex == 1)
   { 
      TextBox1.Text="your batch year is 2011" ;
   }

 }

It is not working. Please help.


Your dropdown list has to have the property AutoPostback=true to fire off the SelectChanged event


protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
     if (ddl.Selectedvalues=="Program")
        TextBox1.Text="your program code is:134" ;
     if (ddl.Selectedvalues=="Batchyear")
        TextBox1.Text="your batch year is 2011" ;


}

DropDown auto Postback True

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜