今天抽空学了一下asp.net和数据库的连接,顺便学习了一下怎么在web里面嵌入字体。昨天弄了个6715个词条的单词的数据库,正好今天测试一下程序!
datagrid 真是好用啊 比起asp来说,强多了!
下面是我做的试验程序。
我的程序演示:http://www.dc9.cn/gre/
这是导入需要用到的命名空间,一个Namespace,就是一个组件,命名空间避免了使用大的对象组(如类库)时的多义性并简化了引用。
| <%@ Import Namespace=”System.Data” %> <%@ Import NameSpace=”System.Data.OleDb” %> |
页面的状态被恢复时候,也就是加载页面的时候,触发Page_OnLoad事件,数据库连接方面和asp差不多,上手也很快..
| <script laguage=”VB” runat=”server”> Dim myConnection As OleDbConnection Dim myCommand As OleDbCommand sub page_load(sender as Object,e as EventArgs) dim dbname as string dbname=server.mappath(“gre.mdb”) myConnection = New OleDbConnection( ”PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=”&dbname ) myConnection.Open() myCommand = New OleDbCommand( ”select top 1000 * FROM www_dc9_cn”, myConnection ) MyDataGrid.DataSource=myCommand.Executereader() MyDataGrid.DataBind() end sub </Script> |
我用weft 生成了这个eot字体文件,目的是显示音标,哈哈这个是从金山词霸抠出来的…词霸这个东西,比韦氏还是查远了…
| <Html> <style type=”text/css”> <!– @font-face{ font-family: Curlz MT; src: url(http://www.dc9.cn/gre/KINGSOF0.eot); } –> </style> <Body> |
哈哈,这个就是著名的~~~datagrid ! .net很值得自豪的一个控件,由于要把音标设成不同的字体,所以我用了AutoGenerateColumns=”False”,一会儿再每一列单设,另外我发现.net居然可以用Alternatingitemstyle-backcolor=”#eeeeee” 这样如此简单的方式来设定间隔行的颜色,真是不错!
| <Asp:datagrid Id=”Mydatagrid” Runat=”Server” AutoGenerateColumns=”False” Bordercolor=”Black” Borderwidth=”1″ Gridlines=”Both” Cellpadding=”3″ Cellspacing=”0″ Font-name=”宋体” Font-size=”10pt” Headerstyle-backcolor=”#aaaadd” Alternatingitemstyle-backcolor=”#eeeeee” > |
接下来就把每一列设置了一下,其中的ItemStyle-Font-Name=”Curlz MT”这句话一直没有找到合适的地方放,开始不知道可以这样设置,查了半天msdn还是没有找到,最后还是在baidu找到方法的=_=||
| <Columns> <asp:TemplateColumn HeaderText=”序号”> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem,”编号”) %> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText=”英文”> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem,”EN”) %> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText=”音标” ItemStyle-Font-Name=”Curlz MT”> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem,”YB”) %> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText=”中文”> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem,”CN”) %> </ItemTemplate> </asp:TemplateColumn> </Columns> </Asp:datagrid> </Body> </Html> |
纵观下来,asp.net的程序设计思路比asp清晰简化了很多,我这只是学了冰山的一角,以后还有很多需要去挖掘,比如今天搞了半天分页,就是没有成功!我的服务器居然不能显示错误原因!调了半天web.config也没有搞定,晕死了-_-无奈自己的机器上没有安装.net framework,刚刚给他下载回来,还没安装…
在datagrid里面加入这段该死的代码总是出错:
AllowPaging=”True”
PageSize=”5″
PagerStyle-HorizontalAlign=”Right”
我的程序演示:http://www.dc9.cn/gre/
欢迎加入.Net的行列。
DataGrid是比较强大,不过个人更喜欢Repeater,Repeater比较容易定制,不像DataGird固定样式。
呵,已经加入啦,i170.com原来没用过,看了看确实是个不错的地方!
哈网上说Repeater控件是DataGrid的一个鲜为人知的兄弟控件~~
偶就直接把petshop里边的分页控件拿了过来用。嘻嘻。
嘿嘿。。过两天偶把工作迟了也来学。NET
版主啊!我也遇到了一个关于网页嵌入字体的麻烦,我这也安装了软件可是就是生成不了那个eot文件啊!!!你能不能帮我生成一个文件然后发给我啊??我的字体是文鼎CS中黑!!!
谢谢!
我的E-mail是:hongzi8418@163.com
版主啊!我也遇到了一个关于网页嵌入字体的麻烦,我这也安装了软件可是就是生成不了那个eot文件啊!!!你能不能帮我生成一个文件然后发给我啊??我的字体是文鼎CS中黑!!!
谢谢了!
我的E-mail是:hongzi8418@163.com
I just want to mention I am new to weblog and certainly loved this page. Almost certainly I’m going to bookmark your website . You absolutely come with fabulous articles and reviews. Cheers for sharing your web page.
A formidable share, I simply given this onto a colleague who was doing just a little analysis on this. And he the truth is bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to discuss this, I really feel strongly about it and love reading extra on this topic. If potential, as you turn out to be experience, would you mind updating your blog with more particulars? It’s extremely useful for me. Massive thumb up for this blog publish!
I like what you guys are up to. Such smart work and reporting! Carry on with the excellent works guys. I’ve incorporated you guys to my blogroll. I think it will improve the value of my web site.
One thing I’d really like to comment on is that weightloss system fast may be accomplished by the proper diet and exercise. People’s size not simply affects appearance, but also the actual quality of life. Self-esteem, depressive disorders, health risks, along with physical ability are affected in an increase in weight. It is possible to make everything right and at the same time having a gain. If this happens, a problem may be the root cause. While excessive food rather than enough physical exercise are usually responsible, common medical conditions and trusted prescriptions may greatly increase size. I am grateful for your post in this article.
Thanks for your strategies. One thing I’ve noticed is that often banks as well as financial institutions know the spending habits of consumers plus understand that most of the people max away their real credit cards around the holiday seasons. They properly take advantage of this real fact and then start flooding your inbox and snail-mail box by using hundreds of 0 APR card offers just after the holiday season concludes. Knowing that if you are like 98% of the American public, you’ll jump at the chance to consolidate personal credit card debt and transfer balances to 0 interest rate credit cards.
Out of my notice, shopping for gadgets online can for sure be expensive, yet there are some how-to’s that you can use to obtain the best discounts. There are constantly ways to uncover discount discounts that could help to make one to come across the best electronic products products at the cheapest prices. Thanks for your blog post.
Can you please send me the code for this script or please inform me in detail regarding this script?