问题描述
我想在点击文章分类选项时下面的条目会自动筛选。以及在点击数据绑定的“主题”这个超链接时会在另一个界面显示这个链接的具体内容,,,先谢谢各位的帮助,这两个问题困扰我好几天了,谢谢。下面是aspx代码<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><divstyle="width:100%;"><asp:LabelID="Label1"runat="server"BackColor="#000066"ForeColor="White"Text="文章分类选项"></asp:Label> <asp:DropDownListID="DropDownList1"runat="server"Height="20px"Width="168px"><asp:ListItemValue="%">全部(不分类)</asp:ListItem><asp:ListItem>C#语言</asp:ListItem><asp:ListItem>论文</asp:ListItem><asp:ListItem>windoe编程</asp:ListItem></asp:DropDownList> 是否分页显示:<asp:RadioButtonListID="RadioButtonList1"runat="server"style="margin-top:0px"AutoPostBack="True"ForeColor="White"RepeatLayout="Flow"Width="167px"OnSelectIndexChanged="RadioButtonList1_SelectIndexChanged"BorderStyle="None"Height="16px"RepeatColumns="2"RepeatDirection="Horizontal"><asp:ListItemSelected="False">不分页</asp:ListItem><asp:ListItem>分页</asp:ListItem></asp:RadioButtonList><br/></div><divstyle="width:100%;height:362px;position:relative;top:0px;left:0px;"><asp:GridViewID="GridView1"runat="server"DataSourceID="SqlDataSource1"AutoGenerateColumns="False"Width="902px"DataKeyNames="主题"ForeColor="#99CCFF"AllowPaging="True"AllowSorting="True"CellPadding="4"><Columns><asp:HyperLinkFieldDataNavigateUrlFields="id,链接文件"DataNavigateUrlFormatString="ArticalShow.aspx?id={0}"DataTextField="主题"HeaderText="主题"Target="_self"Text="主题"/><asp:BoundFieldDataField="分类"HeaderText="分类"SortExpression="分类"/><asp:BoundFieldDataField="发布日期"DataFormatString="{0:yyyy-M-dh:m}"HeaderText="发布日期"HtmlEncode="False"SortExpression="发布日期"/><asp:BoundFieldDataField="发布者"HeaderText="发布者"SortExpression="发布者"/><asp:BoundFieldDataField="浏览次数"HeaderText="浏览次数"SortExpression="浏览次数"/></Columns><RowStyleBackColor="#ff0066"ForeColor="#66ffff"/><EditRowStyleBackColor="#006600"/><PagerStyleBackColor="#00ff00"ForeColor="White"HorizontalAlign="Center"/><HeaderStyleBackColor="#ffff00"Font-Bold="true"BorderColor="White"/><AlternatingRowStyleBackColor="White"ForeColor="#ff9933"/></asp:GridView><asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ConnectionStrings:MyWedDataConnectionString%>"SelectCommand="SELECT*FROM[artical]"><SelectParameters><asp:ControlParameterControlID="DropDownList1"Name="分类"PropertyName="SelectedValue"Type="String"/></SelectParameters></asp:SqlDataSource></div></asp:Content>下面是.cs文件publicpartialclassArtical2:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){CommonMethods.AddBrowerTimes("编程开发");}protectedvoidRadioButtonList1_SelectedIndexChanged(objectsender,EventArgse){GridView1.AllowPaging=!this.GridView1.AllowPaging;}}
解决方案
解决方案二:
下拉框的change事件中,重新加载数据绑定,至于连接,link类型的列,你在datarowbound事件中就可以为其制定url
解决方案三:
您是说在protectedvoidRadioButtonList1_SelectedIndexChanged(objectsender,EventArgse){GridView1.AllowPaging=!this.GridView1.AllowPaging;}这个事件中再用sql语句吗?还有链接这个,用HyperLink结合datarowbound用吗,我是复制书上的代码,实在是太菜鸟了,麻烦您再指点具体一点,谢谢,谢谢。。。。