国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

dpc:Creating a DataBound List of Radio Buttons--預覽

2024-07-21 02:28:01
字體:
來源:轉載
供稿:網友
<% @import namespace="system.data" %>
<% @import namespace="system.data.sqlclient" %>
<script language="vb" runat="server">
  sub page_load(sender as object, e as eventargs)
    if not page.ispostback then
      binddata()
    end if  
  end sub

  
  sub binddata()
    '1. create a connection
    dim myconnection as new sqlconnection(configurationsettings.appsettings("connectionstring"))

    '2. create the command object, passing in the sql string
        const strsql as string = "select publisherid, name from tblpublishers order by name"
        dim mycommand as new sqlcommand(strsql, myconnection)

    myconnection.open()

    radlstpubs.datasource = mycommand.executereader(commandbehavior.closeconnection)
    radlstpubs.databind()  

  end sub



  sub btnviewbooks_click(sender as object, e as eventargs)
    'if the user has not selected an item from the radiobuttonlist,
    'do nothing
    if radlstpubs.selecteditem is nothing then exit sub
    
    '1. create a connection
    dim myconnection as new sqlconnection(configurationsettings.appsettings("connectionstring"))

    '2. create the command object, passing in the sql string
        dim strsql as string = "select title, description from tblbooks " & _
                " where publisherid = " & radlstpubs.selecteditem.value & _
                " order by title"
        dim mycommand as new sqlcommand(strsql, myconnection)

    myconnection.open()

    dgbooks.datasource = mycommand.executereader(commandbehavior.closeconnection)
    dgbooks.databind()  
    
    lbltitle.text = "books published by " & radlstpubs.selecteditem.text
  end sub
</script>

<html>
<body>

  <h1>radio button list demo</h1>
  this demo illustrates how to use data-binding to dynamically
  create a radio button list based on database information.
  the data below is from the
  <a >sample chapters database</a>.
  first, the radio button list is bound to the <code>tblpublishers</code> table.  then,
  when you select a publisher, a datagrid web control is populated with
  the books provided by the selected publisher.  (adding paging to the datagrid would be
  a snap.  just read: <a >paing
  database results in asp.net</a>!)
  <p><hr><p>

  <form runat="server">
    
    <b>choose a publisher's books to view</b><br>
    <asp:radiobuttonlist id="radlstpubs" runat="server" font-name="verdana"
            datavaluefield="publisherid" datatextfield="name" />
    <br>
    <asp:button id="btnviewbooks" runat="server" font-name="verdana"
          text="view published books" onclick="btnviewbooks_click" />
    
    <p align="center">
    <asp:label id="lbltitle" runat="server" font-name="verdana"
          font-size="large" font-bold="true" />
    <asp:datagrid id="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:boundcolumn headertext="book title" headerstyle-horizontalalign="center"
                datafield="title" />
        <asp:boundcolumn headertext="synopsis" headerstyle-horizontalalign="center"
                datafield="description" />
      </columns>
    </asp:datagrid>
    </p>
  </form> <



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 玛沁县| 教育| 绍兴市| 蚌埠市| 伊通| 阳山县| 股票| 中方县| 安平县| 鹤峰县| 任丘市| 郎溪县| 万宁市| 灵宝市| 耒阳市| 濉溪县| 泾川县| 涪陵区| 隆林| 花莲市| 蓬安县| 西乡县| 明光市| 沐川县| 蒙山县| 红桥区| 梅河口市| 温泉县| 进贤县| 兴城市| 阳城县| 威信县| 嘉鱼县| 肇东市| 镇沅| 邯郸县| 通榆县| 中江县| 共和县| 共和县| 信丰县|