连接
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" Text="详情" NavigateUrl='<%#"M.aspx?id="+DataBinder.Eval(Container.DataItem, "id")%>' Runat="server" Target="_blank">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLink Text="打开" NavigateUrl='<%#"newpage.aspx?name="+DataBinder.Eval(Container.DataItem, "vname")+"&age="+DataBinder.Eval(Container.DataItem, "iage") %>' Runat="server" Target="_blank">
ajax的控件工具包AJAX Control Toolkit
http://msdn.microsoft.com/zh-cn/magazine/cc164247.aspx
ModalPopupExtender控件学习笔记 http://www.cnblogs.com/SilverLight/archive/2009/01/08/1319970.html
ModalPopupExtender控件和gridview的结合使用 http://hi.baidu.com/robinapecn/blog/item/ca52f6cfde3b7d0b93457e19.html
前台加上搜索: <table border="0" cellpadding="4" cellspacing="0" style="width: 100%"> <tr><td bgcolor="#f7f7de" colspan="2" style="height: 18px" valign="bottom"> 关键字: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="查找" /></td> </tr> </table> 后台代码: protected void Button1_Click(object sender, EventArgs e) { string res = "SELECT * FROM [city] WHERE ( [cityName] like '%" + TextBox1.Text.ToString() + "%') Order by [cityID] Desc"; SqlDataSource1.SelectCommand = res; GridView1.DataSourceID = "SqlDataSource1"; GridView1.DataBind(); |
Gridview 导出 Excel
private void Export(string FileType, string FileName)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
if (GridView1.Rows[i].Cells[0].Text.Length >= 15)
GridView1.Rows[i].Cells[0].Text = "[" + GridView1.Rows[i].Cells[0].Text.Trim() + "]";
GridView1.Rows[i].Cells[1].Text = "[" + GridView1.Rows[i].Cells[1].Text.Trim() + "]";//格式转为字符
GridView1.Rows[i].Cells[2].Text = "[" + GridView1.Rows[i].Cells[2].Text.Trim() + "]";
//GridView1.Rows[i].Cells[2].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
}
//以下三行可选,如果没有的话导出的只是当前页数据,没有其他页数据
GridView1.AllowPaging = false;
GridView1.AllowSorting = false;
///gridviewdatabind(); //这里是绑定gridview的方法
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
protected void BtnExc_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "学历认证统计表.xls");
}
public override void VerifyRenderingInServerForm(Control control)
{
}