updatepanel没有实现局部刷新
RT。aspx局部代码如下
程序代码:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> <asp:ListItem Text="请跟进" Value="请跟进"></asp:ListItem> <asp:ListItem Text="请核实" Value="请核实"></asp:ListItem> <asp:ListItem Text="已报名" Value="已报名"></asp:ListItem> <asp:ListItem Text="未报名" Value="未报名"></asp:ListItem> </asp:DropDownList> <asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Eval("id") %>' /> </ContentTemplate> </asp:UpdatePanel>.cs DropDownList1_SelectedIndexChanged事件代码如下
程序代码:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { //string value = ((DropDownList)dataListSchool.FindControl("DropDownList1")).SelectedItem.Text; foreach (DataListItem item in dataListSchool.Items) { if ((item.ItemType == ListItemType.Item ) || (item.ItemType == ListItemType.AlternatingItem) || (item.ItemType == ListItemType.SelectedItem)) { string value = ((DropDownList)item.FindControl("DropDownList1")).SelectedValue; int id = Convert.ToInt32(((HiddenField)item.FindControl("HiddenField1")).Value); switch (value) { case "请跟进": DbHelperSQL.ExecuteSql("update person set mark = '请跟进' where id = " + id); break; case "请核实": DbHelperSQL.ExecuteSql("update person set mark = '请核实' where id = " + id); break; case "未报名": DbHelperSQL.ExecuteSql("update person set mark = '未报名' where id = " + id); break; case "已报名": DbHelperSQL.ExecuteSql("update person set mark = '已报名' where id = " + id); break; default: break; } } } }