简体   繁体   中英

value selected afer dropdownlist selected changed event called

I have dropdownlist I want to select a value SELECT File after click on selected change index call.

<asp:DropDownList ID="pdfdropdown" runat="server" AutoPostBack="true" OnSelectedIndexChanged="pdfdropdown_SelectedIndexChanged">
    <asp:ListItem Value="-1">Select file</asp:ListItem>
    <asp:ListItem Value="open">download excel</asp:ListItem>
    <asp:ListItem Value="download">dowload pdf</asp:ListItem>
</asp:DropDownList>


protected void pdfdropdown_SelectedIndexChanged(object sender, EventArgs e)
{              
    pdfdropdown.SelectedValue = "-1";
    Response.AppendHeader("Content-Disposition", "attachment; filename=" + name + ".pdf");
    //......funtions script
}

But I was wonder when i download the file. Selected value is not selected.(After downloading) how can i change a value of dropdown

试试这个

pdfdropdown.Items.FindByValue("-1").Selected = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM