我正在编码一个新的用户控件下拉我的代码是
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="StylishDDL.ascx.cs" Inherits="JDropDown.Controls_StylishDDL" %>
<script src="Jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="Jquery/jquery.selectbox-0.5.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#ddlStytlish').selectbox();
});
</script>
<asp:DropDownList ID="ddlStytlish" runat="server" ClientIDMode="Static">
</asp:DropDownList>
namespace JDropDown
{
public partial class Controls_StylishDDL : UserControl
{
public string _selectedvalue = "";
public int _selectedIndex = 0;
public Controls_StylishDDL( )
{
}
public Controls_StylishDDL(int selectedIndex , string selectedval)
{
SelectedIndx = selectedIndex;
SelectedVal = selectedval;
}
public string SelectedVal
{
get
{
_selectedvalue = this.ddlStytlish.SelectedValue;
return _selectedvalue;
}
set { _selectedvalue = value; }
}
public int SelectedIndx
{
get
{
_selectedIndex = this.ddlStytlish.SelectedIndex;
return this._selectedIndex;
}
set { this._selectedIndex = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
this.ddlStytlish.AutoPostBack = false;
LoadStates();
}
当我使用此控件时,它工作正常,除了它的选定索引始终为 0 并且选定的值始终为空 我如何维护它的索引和值