日期:2014-05-17 浏览次数:20530 次
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" CellPadding="3"
Font-Size="9pt" BackColor="White" BorderColor="#3399FF" BorderStyle="Solid" BorderWidth="1px"
OnPageIndexChanging="fangye" PageSize="10" AllowPaging="True" OnRowDeleting="RowDeleting"
OnRowDataBound="tishi">
<FooterStyle BackColor="White" ForeColor="#000066"/>
<Columns>
<asp:BoundField DataField="id" HeaderText="编号" />
<asp:BoundField DataField="type" HeaderText="分类" HeaderStyle-Width="80px" />
<asp:BoundField DataField="title" HeaderText="标题" HeaderStyle-Width="400px" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="author" HeaderText="作者" HeaderStyle-Width="80px" />
<asp:BoundField DataField="date" HeaderText="发表日期" HeaderStyle-Width="120px" />
<asp:BoundField DataField="num" HeaderText="阅读数" HeaderStyle-Width="80px" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="True"/>
<asp:BoundField DataField="id" HeaderText="修改" HeaderStyle-Width="30px" />
</Columns>
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="white" ForeColor="#000066" HorizontalAlign="Left" CssClass="PagerCss" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White"/>
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
showdata(0);
}
}
//显示数据
protected void showdata(int pageIndex)
{
SqlConnection sqlcon;
string strCon = ConfigurationSettings.AppSettings["ConnectionString"];
string sqlstr = "select * from tjnews where type='发表文章' or type='实验室活动'";
sqlcon = new SqlConnection(strCon);
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);
DataSet myds = new DataSet();