如果没有回发,我有两个DropDownList填充在Page_load上。触发RadioButton回发后,第一个不保留其选择的值。
<asp:Panel ID="Panel1" runat="server" >
<asp:Table ID="tblNew" runat="server" BackColor="#CBE8F5" Width="100%">
<asp:TableRow>
<asp:TableCell>
<asp:DropDownList ID="cmbProveedor" runat="server" DataTextField="NombreCompañia" DataValueField="ProveedorNumero" CssClass="checkbox-round" Width="250px"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:DropDownList ID="cmbBanco" runat="server" DataTextField="banco_nombre" DataValueField="banco_id" CssClass="checkbox-round" Width="250px"></asp:DropDownList>
</asp:TableCell>
<asp:TableCell Width="50%" HorizontalAlign="Left">
<asp:RadioButton ID="chkNormal" runat="server" Text="Normal" GroupName="tipo" OnCheckedChanged="chkTraspasos_CheckedChanged" AutoPostBack="true"></asp:RadioButton>
<asp:RadioButton ID="chkTraspasos" runat="server" Text="Traspaso a Banco" GroupName="tipo" OnCheckedChanged="chkTraspasos_CheckedChanged" AutoPostBack="true"></asp:RadioButton>
</asp:TableCell>
</asp:TableRow>
在回发时,第一个DropDownList不会保留其值,而第二个。
protected void Page_Load(object sender, EventArgs e)
{
client_id = Request.Cookies["ClientId"].Value;
corp_id = Request.Cookies["CorpId"].Value;
company = Request.Cookies["EmpresaId"].Value;
user_id = Request.Cookies["UserID"].Value;
C = new Tesoreria.Cheques(company);
if (!Page.IsPostBack){
P = new Proveedores(company);
P.Get_proveedores(client_id, corp_id, company, user_id);
cmbProveedor.DataSource = P.GetData();
cmbProveedor.DataBind();
Banco = new Tesoreria(company);
Banco.Get_Bancos(client_id, corp_id, company, user_id);
cmbBanco.DataSource = Banco.GetData();
cmbBanco.DataBind();