我想在asp.net c#中打印多个值: Default.aspx
<asp:DropDownList runat="server" ID="ddlSkills" CssClass="form-control" multiple="multiple" >
<asp:ListItem Value="HTML5">HTML5</asp:ListItem>
<asp:ListItem Value="CSS3">CSS3</asp:ListItem>
<asp:ListItem Value="JavaScript">JavaScript</asp:ListItem>
<asp:ListItem Value="C#.NET">C#.NET</asp:ListItem>
<asp:ListItem Value="Java">Java</asp:ListItem>
<asp:ListItem Value="PHP">PHP</asp:ListItem>
</asp:DropDownList>
<br /><br />
<asp:Button runat="server" ID="btnSave" CssClass="btn btn-primary" Text="Save" OnClick="btnSave_Click" />
我只是从多个数据中打印一个数据: Default.aspx.cs 页面
protected void btnSave_Click(object sender, EventArgs e)
{
string message = "";
foreach(ListItem item in ddlSkills.Items)
{
if(item.Selected)
{
message += item.Text;
}
}
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + message + "');", true);
}