设为首页】 【加入收藏】 【网站地图】 【商品折扣
娱乐一生 娱乐明星
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
首页  |  java  |  .NET  |  C/C++  |  网页技术  |  php  |  asp  |  delphi  |  VC  |  VB开发  |  游戏开发  |  软件工程  |  Power Builder  |  Linux开发  |  Windows开发技巧
当前位置:首页 >> 开发实例 >> Form code generator V1.1 by Steve Schofield[bate2 等级:中级](转载:a free)

Form code generator V1.1 by Steve Schofield[bate2 等级:中级](转载:a free) -

This article revolves around being plain lazy. When it comes to creating Form code based on some database table, I hate it! This code sample goes along way in  eeding this proce  up for me. There still is some manual parts to finish up the form code but this takes care of remembering what colum  are in the database table. In future releases, we'll provide more functionality to further automate this but this is a big first step in my opinion! The following four ste  listed below can be followed and this will generate the A .NET code. A big thanks to Dave W. Webmaster of for saving me on many things!!

Define what database you want to co ect to in the config.web. This is stored in the co ection string
<configuratio gt;
 lt;a etting gt;
 lt;add key="d quot; value=" erver=localhost;uid=sa wd=;database=a free" />
 lt;/a etting gt;
</configuratio gt;
Load the a x page in your browser, select the table to create the Form code from
Select the checkboxs of which fields to be on the form
Copy and paste into your code..
Here is a screen shot of the File after following the above ste .



Here is the code:

<%@ Page Language="V quot; EnableSe io tate="False" EnableViewState="True" Trace="False" Debug="False" Strict="True" %>
<%@ Import Name ace=" ystem.Text" %>
<%@ Import Name ace=" ystem.Data" %>
<%@ Import Name ace=" ystem.Data.SqlClient" %>
< cript language="V quot; runat=" erver" gt;
Dim sqlText as String
Dim ds as New DataSet
Dim dbComm AS New SQLDataAdapter
Dim co  AS SQLCo ection
Dim sqlServer as String

Sub Page_Load(sender As Object, e As EventArgs)

 QLserver = GetSqlCo ()
 co  = New SQLCo ection(SQLserver)


 If Not I ostBack then
 qlText = " elect id, name from sysobjects where xtype='U' order by name"
 dbComm = New SQLDataAdapter(sqlText,co )
 dbComm.Fill(ds,"AllTable quot;)
 tblList.DataSource = ds.Tables("AllTable quot;).DefaultView
 tblList.DataTextField = " ame"
 tblList.DataValueField = " ame"
 tblList.DataBind()
End if


End Sub

Function CreateValidator(myName as string) as String
 Dim my  as StringBuilder = New StringBuilder()

 REM -- use :< ome text>: as placeholders
 my .A end (" lt;a :RequiredFieldValidator runat=" quot erver" quot; id=" quot;:Name:" quot; ControlToValidate=" quot;:control:" quot; ErrorMe age=" quot;:errMsg:" quot; di lay=" quot tatic" quot gt;This Required Field!</a :RequiredFieldValidator> quot; )

 my .Replace(":Name:","vld" & myName) 'add the validator name
 my .Replace(":control:","at" & myName) 'add the control name
 my .Replace(":errMsg:",myName & " is required")

Return my .ToString()

End Function


Function GetSqlCo () as String
 Dim D  as String = Configuratio ettings.A ettings("D quot;)
 Return D 
End Function


Sub GetTable_Click(sender As Object, e As EventArgs)
 Dim sqlText as String
 qlText = " ELECT syscolum .name, syscolum .i ullable FROM sysobjects I ER JOIN syscolum  ON sysobjects.id = syscolum .id where sysobjects.name = '" & tblList.SelectedItem.Text & "' ORDER BY syscolum .colid"

REM -- Co ect to SQL
 dbComm = New SQLDataAdapter(sqlText,co )

REM -- Fill DataSet
 dbComm.Fill(ds,"TestData")
 MyDataGrid.DataSource = ds.Tables("TestData").DefaultView
 MyDataGrid.DataBind()


REM -- Show the results
 myPanel.Visible= True

End Sub



Sub Button1_Click(sender As Object, e As EventArgs)

 Dim i As Integer
 Dim _item As DataGridItem
 Dim dr As DataRow
 Dim   as StringBuilder = New StringBuilder()
 Dim strOutput as String

REM -- Auto Generate The Form
 .A end( " lt;form runat=" quot erver" quot; id=" quot;form2" quot; name=" quot;form2" quot gt quot; & Chr(13) & Chr(10) )
 .A end( " <table border=1> quot; & chr(13))


 For i = 0 To MyDataGrid.Items.Count - 1
REM -- Get the checkbox
 _item = MyDataGrid.Items(i)
 Dim addCheckBox As CheckBox = Ctype(_item.FindControl("chkAdd"),CheckBox)
 Dim validCheckBox as CheckBox = Ctype(_item.FindControl("chkValid"),CheckBox)

 If addCheckBox.Checked then
 .A end( " <tr> quot; & chr(13))
 .A end( " <td> quot; & _item.Cells(1).Text & " lt;/td> quot; & chr(13))
 



 

娱乐图摘

更多 >>

靓丽清纯美女meimei

美女私房全裸照
导演劝女演员脱衣服(视频)

大胆火辣人体艺术写真(图)

黑丝妹妹热辣诱惑-丝袜美女妹妹

PLMM 漂亮妹妹图集-妹妹图库

全球美女图库-美女集中营

52MM 我爱漂亮妹妹-制服妹妹诱惑

图王图库-世界美女明星图片资料库
美女写真集锦

激情两性-解密性生活
浴室MM湿身内衣诱惑
邻家小妹洗澡被偷拍(视频)

热点文章

更多

· A .NET验证控件祥解(转)
· A .net:Literal控件用法
· A .NET中文件上传下载方法集合
· A .NET中Cookie编程的基础知识(3)
· A .net 验证码(C#)
· 在A .Net中创建动态表格
· 设计A .NET新闻管理系统
· 将A .NET页面内的数据导出到Excel&nbs
· A .Net2.0 GridView&n
· 利用A .NET设计FTP文件上传

热点文章

更多