·½·¨Ò»:
н¨Ò»¸öÒ³ÃæÈ»ºóÔÚÒ³ÃæÍÏÒ»¸öGridView¿Ø¼þÔÚÊôÐÔ¿òÖÐÉèÖÃGridView¿Ø¼þµÄAllowPaingÊôÐÔΪTrue È»ºóÔÙÉèÖÃGridViewµÄPageSizeÊôÐÔ,Ô´ÎļþÈçÏÂ:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames ="classId" CellPadding="5" OnRowDeleting="GridView1_RowDeleting" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" PageSize ="15">
<Columns>
<asp:BoundField DataField ="className" HeaderText ="Ãû³Æ" />
<asp:BoundField DataField="classDes" HeaderText="ÃèÊö" SortExpression="classDes" />
</Columns>
<PagerTemplate>
&n ......
½ñÌì¸ø¿Í»§×öÁ˸ö¹¦ÄÜÐèÒª°ÑÍø¸ñÊý¾Ý£¨Gridview£©µ¼³ö³ÉExecl£¬ËùÒÔÎÒÈ¥ÍøÉÏÕÒÁ˸ö´úÂë private void Export(string FileType, string FileName)
...{
try
...{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
grdSearch.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
catch (Exception err)
...{
DOMUtility.PopAlertWindow("µ¼³öExcel³ö´í£¡´íÎóÔÒò£º" + err.Message);
//return false;
}
}
µ«ÊÇÕâÖÖ·½·¨µÄ»°Ö»Êǰѵ±Ç°GridviewÒ³µ¼³öµ½Excel£¬¶ø¿Í»§ÐèÒª°Ñµ±Ç°ËùÒÔ·ÖÒ³µÄÊý¾Ýµ¼³öµ½Excel£¬²¢ÇÒÔÚ¿Í»§¶Ë´ò¿ª£¬ËùÒÔÏëÁËÏëÓм¸ÖÖ·½°¸£º
1£©½«execlÎļþµ¼³öµ½·þÎñÆ÷ÉÏ£¬ÔÙÏÂÔØ¡£ÕâÑùµÄ»°·þÎñÆ÷ÖÐÓжàÓàµÄÎļþÁË¡£²»Í¨¹ý
2£©½«DataSetÖеÄÊý¾Ýµ¼³ ......
½ñÌì¸ø¿Í»§×öÁ˸ö¹¦ÄÜÐèÒª°ÑÍø¸ñÊý¾Ý£¨Gridview£©µ¼³ö³ÉExecl£¬ËùÒÔÎÒÈ¥ÍøÉÏÕÒÁ˸ö´úÂë private void Export(string FileType, string FileName)
...{
try
...{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
grdSearch.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
catch (Exception err)
...{
DOMUtility.PopAlertWindow("µ¼³öExcel³ö´í£¡´íÎóÔÒò£º" + err.Message);
//return false;
}
}
µ«ÊÇÕâÖÖ·½·¨µÄ»°Ö»Êǰѵ±Ç°GridviewÒ³µ¼³öµ½Excel£¬¶ø¿Í»§ÐèÒª°Ñµ±Ç°ËùÒÔ·ÖÒ³µÄÊý¾Ýµ¼³öµ½Excel£¬²¢ÇÒÔÚ¿Í»§¶Ë´ò¿ª£¬ËùÒÔÏëÁËÏëÓм¸ÖÖ·½°¸£º
1£©½«execlÎļþµ¼³öµ½·þÎñÆ÷ÉÏ£¬ÔÙÏÂÔØ¡£ÕâÑùµÄ»°·þÎñÆ÷ÖÐÓжàÓàµÄÎļþÁË¡£²»Í¨¹ý
2£©½«DataSetÖеÄÊý¾Ýµ¼³ ......
ͬÑùÊÇһƪתÌûµÄÎÄÕÂ,
ÔÎÄ: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-2-modelmetadata.html
×ÅÖØ½éÉÜÁËASP.NET MVC2 ÀïÃæµÄ ModelMetadata Àà
ASP.NET MVC 2 Templates, Part 2: ModelMetadata
Series Index
Part 1: Introduction
Part 2: ModelMetadata
Understanding Your Model
One
of the classes we introduced with ASP.NET MVC 2 is ModelMetadata. This
class is designed to tell you interesting things about the objects you
want to display or edit. While we commonly use them when writing
templates, this metadata is actually always available, even when you’re
not in a template.
What is a Model?
When it comes to ModelMetadata, the definition of “model” is probably a bit blurrier than you’re used to.
Let’s say for instance that you have the model from part 1 of this blog series:
view sourceprint?
1.public class Contact {
2. public string FirstName { get; set; }
3. public stri ......
try
{
string _conStr = "Driver={MySQL ODBC 3.51
Driver};server=localhost;database=test;uid=test;password=1;option=3";
OdbcConnection _odbcCon = new OdbcConnection(_conStr);
_odbcCon.Open();
OdbcTransaction trans = _odbcCon.BeginTransaction
(IsolationLevel.ReadCommitted);
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = trans.Connection;
cmd.Transaction = trans;
string _sqlStr = "";
......
try
{
string _conStr = "Driver={MySQL ODBC 3.51
Driver};server=localhost;database=test;uid=test;password=1;option=3";
OdbcConnection _odbcCon = new OdbcConnection(_conStr);
_odbcCon.Open();
OdbcTransaction trans = _odbcCon.BeginTransaction
(IsolationLevel.ReadCommitted);
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = trans.Connection;
cmd.Transaction = trans;
string _sqlStr = "";
......
asp.netµ¯³ö´°Ìå´óÈ«
<SCRIPT LANGUAGE="javascript">
¡¡¡¡<!--
¡¡¡¡window.open ('page.html')
¡¡¡¡-->
¡¡¡¡</SCRIPT>
¡¡¡¡
¡¡¡¡ÒòΪ×ÅÊÇÒ»¶Îjavascripts´úÂ룬ËùÒÔËüÃÇÓ¦¸Ã·ÅÔÚ<SCRIPT LANGUAGE="javascript">±êÇ©ºÍ</script>Ö®¼ä¡£<!-- ºÍ -->ÊǶÔһЩ°æ±¾µÍµÄä¯ÀÀÆ÷Æð×÷Óã¬ÔÚÕâЩÀÏä¯ÀÀÆ÷Öв»»á½«±êÇ©ÖеĴúÂë×÷ΪÎı¾ÏÔʾ³öÀ´¡£ÒªÑø³ÉÕâ¸öºÃϰ¹ß°¡¡£window.open ('page.html') ÓÃÓÚ¿ØÖƵ¯³öеĴ°¿Úpage.html£¬Èç¹ûpage.html²»ÓëÖ÷´°¿ÚÔÚͬһ·¾¶Ï£¬Ç°ÃæÓ¦Ð´Ã÷·¾¶£¬¾ø¶Ô·¾¶(http://)ºÍÏà¶Ô·¾¶(../)¾ù¿É¡£Óõ¥ÒýºÅºÍË«ÒýºÅ¶¼¿ÉÒÔ£¬Ö»ÊDz»Òª»ìÓá£ÕâÒ»¶Î´úÂë¿ÉÒÔ¼ÓÈëHTMLµÄÈÎÒâλÖã¬<head>ºÍ</head>Ö®¼ä¿ÉÒÔ£¬<body>¼ä</body>Ò²¿ÉÒÔ£¬Ô½Ç°Ô½ÔçÖ´ÐУ¬ÓÈÆäÊÇÒ³Ãæ´úÂ볤£¬ÓÖÏëÊ¹Ò³ÃæÔçµãµ¯³ö¾Í¾¡Á¿Íùǰ·Å¡£
¡¡
¡¡ ¡¾2¡¢¾¹ýÉèÖúóµÄµ¯³ö´°¿Ú¡¿
¡¡¡¡
¡¡¡¡ÏÂÃæÔÙ˵һ˵µ¯³ö´°¿ÚµÄÉèÖá£Ö»ÒªÔÙÍùÉÏÃæµÄ´úÂëÖмÓÒ»µã¶«Î÷¾Í¿ÉÒÔÁË¡£ ÎÒÃÇÀ´¶¨ÖÆÕâ¸öµ¯³öµÄ´°¿ÚµÄÍâ¹Û£¬³ß´ç´óС£¬µ¯³öµÄλÖÃÒÔÊÊÓ¦¸ÃÒ³ÃæµÄ¾ßÌåÇé¿ö¡£
¡¡¡¡
¡¡¡¡<SCRIPT LANGUAGE="javascript">
¡¡¡¡<! ......
ASP.NETʵÏÖ×ÔÊÊӦͼƬ´óСµÄµ¯³ö´°¿Ú
ÔÚ×î½üµÄÏîÄ¿ÖУ¬Óöµ½Ò»¸öÎÊÌ⣬ҪʵÏÖÕâÑùµÄЧ¹û£º
µãpic_small.AspxÒ³ÃæµÄËõÂÔͼºóµ¯³öpic_all.aspxÒ³Ãæ£¬pic_all.aspxÒ³ÃæµÄ´óСҪ¸ù¾ÝͼƬ´óС×Ô¶¯µ÷Õû£¬¶øÇÒÒªÓÐͼƬµÄ˵Ã÷ÐÅÏ¢£¬»¹¿ÉÒÔµãÉÏÒ»·ùºÍÏÂÒ»·ùµÈ½øÐзҳ¡£
ʵÏÖ¹ý³ÌÈçÏ£º
pic_small.AspxÒ³ÃæËõÂÔͼ´¦µÄ´úÂëΪ£º
£¼IMG id="imgPic" style="CURSOR: hand" border=0 height="95" onclick="ShowWindow(£¼%#DataBinder.Eval(Container.DataItem,"ID")%>)" src='£¼%#"Images/Product/" + DataBinder.Eval(Container.DataItem,"PicUrl")%>' width="118" runat="server">
ShowWindow±£´æÔÚOpenWindows.jsÎļþÖУ¬ÄÚÈÝÈçÏ£º
function ShowWindow(id)
{
window.open('pic_all.aspx?ID=' + id,'_blank','Scrollbars=no');
}
ÒÔÏ´úÂë¼´¿ÉʵÏÖµãËõÂÔͼºóµ¯³öÒ³Ãæpic_all.aspxÏÔʾͼƬÐÅÏ¢£¬ÏÂÃæÒªÊµÏÖµÄÊÇpic_all.aspxÒ³Ãæ¸ù¾ÝͼƬµÄ´óС×Ô¶¯µ÷Õû¡£
°ÑÒÔÏ´úÂë·ÅÔÚpic_all.aspxÒ³ÃæµÄ£¼Head>£¼/Head>Ö®¼ä£º
£¼script>
function window.onload()
{
var obj=document.getElementById("PicUrl");
window.resizeTo(obj.offsetWidth + 12 ......