Posted By

krisdb on 04/10/08


Tagged

c-sharp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


DropDown List Control


 / Published in: C#
 

  1. <asp:DropDownList ID="ddlList" runat="server" />
  2.  
  3. <asp:RequiredFieldValidator ID="rfvList" ControlToValidate="ddlList"
  4. runat="server" EnableClientScript="false" CssClass="validation">*</asp:RequiredFieldValidator>
  5.  
  6.  
  7. ddlList.DataSource = DataSelection.ReturnDataTable("sp_StoredProc");
  8.  
  9. ddlList.DataValueField = "item_value";
  10. ddlList.DataTextField = "display_text";
  11. ddlList.DataBind();
  12.  
  13. ddlList.Items.Insert(0, new ListItem("--Select--", ""));
  14.  
  15. if (ddlList.Items.FindByValue("") != null)
  16. ddlList.Items.FindByValue("").Selected = true;
  17.  
  18.  
  19. ddlList.SelectedItem.Value;
  20.  
  21. public string SelectedValue
  22. {
  23. get
  24. {
  25. return ddlList.SelectedValue;
  26. }
  27. set
  28. {
  29. ddlList.SelectedValue = value;
  30. }
  31. }
  32.  
  33. public string Width
  34. {
  35. set
  36. {
  37. ddlCountries.Width = value;
  38. }
  39. }
  40.  
  41. public string id
  42. {
  43. set
  44. {
  45. ddlList.ID = value;
  46. }
  47. }
  48.  
  49. public string ValidationEnabled
  50. {
  51. set
  52. {
  53. rfvList.Enabled = Convert.ToBoolean(value);
  54. }
  55. }
  56.  
  57.  
  58. public string ValidationGroup
  59. {
  60. set
  61. {
  62. ddlList.ValidationGroup = value;
  63. }
  64. }
  65.  
  66. public string ValidationErrorMessage
  67. {
  68. set
  69. {
  70. rfvList.ErrorMessage = value;
  71. }
  72. }
  73.  
  74. public short TabIndex
  75. {
  76. set
  77. {
  78. ddlList.TabIndex = value;
  79. }
  80. }

Report this snippet  

You need to login to post a comment.