DropDownList 选择新闻类别,点listView下一页时怎么又类别错乱了呢
<table id="t1" runat="server" border="0" style="text-align:center;width:98%;" cellpadding="4" cellspacing="1" ><tr><td colspan="2">
<asp:ListView ID="LvNews" runat="server" DataKeyNames="Id" >
<ItemTemplate>
<tr >
<td align="center">
<%#Eval("NewsType") %>
</td>
<td align="center">
<font color="">
<%#Eval("NewsTitle") %></font>
</td>
<td align="center">
<%#Eval("NewsDatetime")%>
</td>
<td align="center">
<a href="NewsEdit.aspx?id=<%#Eval("Id") %>&cat=<%#Eval("NewsCat") %>" title="点击修改该新闻">修改</a>
</td>
<td>
<asp:CheckBox ID="checkgoods" runat="server" Text='<%#Eval("Id") %>' />
</td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server" style="">
<tr>
<td>
没有数据 </td>
</tr>
</table>
</EmptyDataTemplate>
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" >
<tr class="thead">
<td style="width:100px;" >
所属栏目
</td>
<td style="width:230px;">
标题
</td>
<td style="width:110px;" >
添加日期
</td>
<td style="width:80px;" >
修改
</td>
<td style="width:80px">
删除
</td>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
</td>
</tr>
<tr >
<td align="center">
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="LvNews"
QueryStringField="pagenum"
PageSize="6" onprerender="DataPager1_PreRender" >
<Fields>
<asp:NextPreviousPagerField FirstPageText="首页" ShowFirstPageButton="True"
ShowNextPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField LastPageText="末页" ShowLastPageButton="True"
ShowPreviousPageButton="False" />
<asp:TemplatePagerField>
<PagerTemplate>
<input type="text" id="goPagenum" style="width:30px;height:18px;"/><input type="button" id="goBtn" value="跳转" />
</PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>
</td>
<td>
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:Button ID="BtnCheck1" runat="server" Text="全选" />
<asp:Button ID="BtnDelete1" runat="server" Text="删除" />
</td>
</tr>
</table>
后台代码
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
protected void Ddlsearch_SelectedIndexChanged(object sender, EventArgs e)
{
Bind();
}
protected void Bind()
{
if (!IsPostBack)
{
try
{
string sql = "select * from T_News order by NewsDatetime desc";
LvNews.DataSource = 韩蒸天下.App_Code.Model.News.GetSet(sql);
LvNews.DataBind();
}
catch (Exception er)
{
throw new Exception(er.Message);
}
}
else
{
if (Ddlsearch.SelectedValue != "所有新闻")
{
string sql = "select * from T_News where NewsType='" + Ddlsearch.SelectedValue + "' order by NewsDatetime desc";
LvNews.DataSource = 韩蒸天下.App_Code.Model.News.GetSet(sql);
LvNews.DataBind();
}
else
{
string sql = "select * from T_News order by NewsDatetime desc";
LvNews.DataSource = 韩蒸天下.App_Code.Model.News.GetSet(sql);
LvNews.DataBind();
}
}
}
protected void DataPager1_PreRender(object sender, EventArgs e)
{
LvNews.DataBind();
} --------------------编程问答-------------------- 各位大神小弟是新人,救救小弟吧,一会老板就要看成果了 啊
--------------------编程问答-------------------- 没人顶吗
补充:.NET技术 , ASP.NET