|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
前天傍晚我发表了《Java的跨平台就是一句谎言。》,原本就是周末闲来无事,发表一篇略带争议性的博文让大家都来吵吵架,发表自己的看法,根本就没想着谁把谁打倒,一个行业或者是技术阵营是无法用短期口水仗打到对手的。<%@ImportNamespace="System.Data"%>
<%@ImportNamespace="System.Data.SqlClient"%>
<scriptlanguage="vb"runat="server">
SubPage_Load(senderasObject,easEventArgs)
IfNotPage.IsPostBackthen
BindData()
EndIf
EndSub
SubBindData()
1.Createaconnection
DimmyConnectionasNewSqlConnection(ConfigurationSettings.AppSettings("connectionString"))
2.Createthecommandobject,passingintheSQLstring
ConststrSQLasString="SELECTPublisherID,NameFROMtblPublishersORDERBYName"
DimmyCommandasNewSqlCommand(strSQL,myConnection)
myConnection.Open()
radlstPubs.DataSource=myCommand.ExecuteReader(CommandBehavior.CloseConnection)
radlstPubs.DataBind()
EndSub
SubbtnViewBooks_Click(senderasObject,easEventArgs)
Iftheuserhasnotselectedanitemfromtheradiobuttonlist,
donothing
IfradlstPubs.SelectedItemIsNothingthenExitSub
1.Createaconnection
DimmyConnectionasNewSqlConnection(ConfigurationSettings.AppSettings("connectionString"))
2.Createthecommandobject,passingintheSQLstring
DimstrSQLasString="SELECTTitle,DescriptionFROMtblBooks"&_
"WHEREPublisherID="&radlstPubs.SelectedItem.Value&_
"ORDERBYTitle"
DimmyCommandasNewSqlCommand(strSQL,myConnection)
myConnection.Open()
dgBooks.DataSource=myCommand.ExecuteReader(CommandBehavior.CloseConnection)
dgBooks.DataBind()
lblTitle.Text="BooksPublishedby"&radlstPubs.SelectedItem.Text
EndSub
</script>
<html>
<body>
<h1>RadioButtonListDemo</h1>
Thisdemoillustrateshowtousedata-bindingtodynamically
createaradiobuttonlistbasedondatabaseinformation.
Thedatabelowisfromthe
<ahref="http://www.4guysfromrolla.com/webtech/chapters/">SampleChaptersDatabase</a>.
First,theradiobuttonlistisboundtothe<code>tblPublishers</code>table.Then,
whenyouselectapublisher,aDataGridWebcontrolispopulatedwith
thebooksprovidedbytheselectedpublisher.(AddingpagingtotheDataGridwouldbe
asnap.Justread:<ahref="http://www.4guysfromrolla.com/webtech/072101-1.shtml">Paing
DatabaseResultsinASP.NET</a>!)
<p><hr><p>
<formrunat="server">
<b>ChooseaPublishersBookstoView</b><br>
<asp:radiobuttonlistid="radlstPubs"runat="server"Font-Name="Verdana"
DataValueField="PublisherID"DataTextField="Name"/>
<br>
<asp:buttonid="btnViewBooks"runat="server"Font-Name="Verdana"
Text="ViewPublishedBooks"/>
<palign="center">
<asp:labelid="lblTitle"runat="server"Font-Name="Verdana"
Font-Size="Large"Font-Bold="True"/>
<asp:datagridid="dgBooks"runat="server"
Font-Name="Verdana"Font-Size="Smaller"
HeaderStyle-BackColor="Purple"HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="Small"HeaderStyle-Font-Bold="True"
AutoGenerateColumns="False">
<Columns>
<asp:BoundColumnHeaderText="BookTitle"HeaderStyle-HorizontalAlign="Center"
DataField="Title"/>
<asp:BoundColumnHeaderText="Synopsis"HeaderStyle-HorizontalAlign="Center"
DataField="Description"/>
</Columns>
</asp:datagrid>
</p>
</form><
[img=1border=0style=,1src=]http://www.ckuyun.com/[/img]
有个问题想请教你一下,呵呵:)你觉得将来学什么方向比较好,我真是想不出来,知道的太少了,麻烦了。 |
|