您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp.net >> 正文

DPC:Creating a DataBound List of Radio Buttons--预览页面source code等级:中

作者:作者:未…    信息学院来源:网络收集    点击数:    更新时间:2006-8-28 我要参与讨论

  &lt;% @Import Namespace=&quot;System.Data&quot; %&gt;<br>
&lt;% @Import Namespace=&quot;System.Data.SqlClient&quot; %&gt;<br>
&lt;script language=&quot;vb&quot; runat=&quot;server&quot;&gt;<br>
&nbsp;&nbsp;Sub Page_Load(sender as Object, e as EventArgs)<br>
&nbsp;&nbsp;&nbsp;&nbsp;If Not Page.IsPostBack then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BindData()<br>
&nbsp;&nbsp;&nbsp;&nbsp;End If&nbsp;&nbsp;<br>
&nbsp;&nbsp;End Sub<br>
<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;Sub BindData()<br>
&nbsp;&nbsp;&nbsp;&nbsp;'1. Create a connection<br>
&nbsp;&nbsp;&nbsp;&nbsp;Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings(&quot;connectionString&quot;))<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;'2. Create the command object, passing in the SQL string<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Const strSQL as String = &quot;SELECT PublisherID, Name FROM tblPublishers ORDER BY Name&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim myCommand as New SqlCommand(strSQL, myConnection)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;myConnection.Open()<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;radlstPubs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)<br>
&nbsp;&nbsp;&nbsp;&nbsp;radlstPubs.DataBind()&nbsp;&nbsp;<br>
<br>
&nbsp;&nbsp;End Sub<br>
<br>
<br>
<br>
&nbsp;&nbsp;Sub btnViewBooks_Click(sender as Object, e as EventArgs)<br>
&nbsp;&nbsp;&nbsp;&nbsp;'If the user has not selected an item from the radiobuttonlist,<br>
&nbsp;&nbsp;&nbsp;&nbsp;'do nothing<br>
&nbsp;&nbsp;&nbsp;&nbsp;If radlstPubs.SelectedItem Is Nothing then Exit Sub<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;'1. Create a connection<br>
&nbsp;&nbsp;&nbsp;&nbsp;Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings(&quot;connectionString&quot;))<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;'2. Create the command object, passing in the SQL string<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim strSQL as String = &quot;SELECT Title, Description FROM tblBooks &quot; & _<br>
&nbsp;&nbsp;&nbsp;&nbsp;&

[1] [2] [3] [4] 下一页

在google里搜索更多DPC:Creating a DataBound List of Radio Buttons--预览页面source code等级:中

Google
Web www.51ec.org
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
我来说两句 对此文章发表了评论
  昵 称: *必填    ·注册用户·
  评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
评 论
内 容

 
评论列表 (最新 评论仅限网友观点!)

供求信息




| 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明