亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 編程 > Perl > 正文

在datagrid中的HyperLinkColumn上達到談出一個窗口的效果

2024-07-21 02:17:00
字體:
來源:轉載
供稿:網友
creating a popup window details grid in a datagrid  
this articles topic came from the suggestion of a true dotnetjunkie. he originally sent an email to us asking for an example illustrating how to make a hyperlinkcolumn in a datagrid spawn events that would pop up a new window with details of the row that the user clicked on. before we could anwser his email he had already emailed us back explaining that he had found a way to do it and suggested a tutorial of his discovery. so, here it is! as with most of our articles, this simplifies the task, but easy examples of coding techniques is what gives developers ideas for more complex senerios.  
this example contains two webforms and one external style sheet (all code is included in the download) - the first webform contains a datagrid with a list of products from the northwind database and a hyperlink that states "seedetails". once this link is clicked the javascript window.open method is used to open a new window. within the url is a query string parameter of the productid of the product the user wants the details for. in the second webform there is another datagrid that shows the user all the details for the chosen product. the stylesheet is used just because its cleaner to use than inline styles. so lets take a look at webform1.aspx and webform1.aspx.cs  
webform1.aspx  
<%@ page language="c#" autoeventwireup="false" inherits="howtos.datagrid.popupwindow.webform1" %>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
  <head>
   <link rel="stylesheet" type="text/css" href="stylesheet1.css"></link>
  </head>
   <body>
    <center>
        <form runat="server" id="form1">
            <asp:datagrid id="datagrid1" runat="server" font-size="12" autogeneratecolumns="false">
            <columns>
            <asp:boundcolumn datafield= "productid" headertext= "product id" headerstyle-cssclass="headerstyle" itemstyle-cssclass="itemstyledefault" />
            <asp:boundcolumn datafield="productname" headertext="productname" headerstyle-cssclass="headerstyle" itemstyle-cssclass="itemstyledefault"/>
            <asp:hyperlinkcolumn datatextformatstring="showdetails..." datatextfield="productid" datanavigateurlfield="productid" datanavigateurlformatstring="javascript:varwin=window.open('webform2.aspx?productid={0}',null,'width=692,height=25');" headertext="see details" headerstyle-cssclass="headerstyle" itemstyle-cssclass="itemstylehyperlink" />
//其實整個文章只要看這么一句就可以了。。。點睛之筆就是它了
            </columns>
            </asp:datagrid>
        </form>
     </center>
   </body>
</html>


webform1.aspx.cs  
using system;
using system.collections;
using system.componentmodel;
using system.data;
using system.data.sqlclient ;
using system.drawing;
using system.web;
using system.web.sessionstate;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.htmlcontrols;

  namespace howtos.datagrid.popupwindow
  {

    public class webform1 : system.web.ui.page
    {
      protected system.web.ui.webcontrols.datagrid datagrid1;

        #region user defined code

        private void page_load(object sender, system.eventargs e)
        {

                if ( ! this.ispostback )  
                this.binddata();

        }

        protected void binddata()
        {

                sqlcommand cmd = new sqlcommand( "select top 10 productid, productname from products", con("server=localhost; database=northwind; trusted_connection=true"));  
                this.datagrid1.datasource = cmd.executereader(commandbehavior.closeconnection);
                this.datagrid1.databind();

        }  

        protected sqlconnection con(system.string connectionstring )
        {

                sqlconnection c = new sqlconnection( connectionstring );
                c.open();  
                return c;

        }

        #endregion

        #region web form designer generated code

        override protected void oninit(eventargs e)
        {
                
                initializecomponent();
                base.oninit(e);
        
        }

        private void initializecomponent()
        {  
                
                this.load += new system.eventhandler(this.page_load);
        
        }

#endregion

  }
}  
there isn't really anything out of the ordinary on here except for the details of datanavigateurlformatstring you'll notice that i actually have javascript window.open directly in it (note: i could have just as easily created an external .js file or <script></script> within the webform - i used it inline for simplicity. this javascript code should look familiar to all so i won't go into discussion about it. essentially, it will open a new browser with the page webform2.aspx with a query string parameter productid. this value is the productid from our data source. so let's look at webform2.aspx and webform2.aspx.cs  
webform2.aspx  
<%@page language="c#" autoeventwireup="false" inherits="howtos.datagrid.popupwindow.webform2" %>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
  <head>
    <title>product details</title>
    <link rel="stylesheet" type="text/css" href="stylesheet1.css"></link>
  </head>
    <body>
      <asp:datagrid headerstyle-cssclass="headerstyle" itemstyle-cssclass="itemstyledefault" runat="server" id="datagrid1" font-size="8" height="50" width="675"></asp:datagrid>
      <p align="center">
      <a href="javascript:window.close()">close window</a>
      </p>
    </body>
</html>

webform2.aspx.cs
using system;
using system.collections;
using system.componentmodel;
using system.data;
using system.data.sqlclient ;
using system.drawing;
using system.web;
using system.web.sessionstate;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.htmlcontrols;

namespace howtos.datagrid.popupwindow
{

  public class webform2 : system.web.ui.page
  {
    protected system.web.ui.webcontrols.datagrid datagrid1;

    #region user defined code

    private void page_load(object sender, system.eventargs e)
    {
        if ( ! this.ispostback )  
          this.binddata();
    }

    protected void binddata()
    {
      sqlcommand cmd = new sqlcommand( "select * from products where productid = @productid", con("server=localhost; database=northwind; trusted_connection=true"));  
      cmd.parameters.add(new sqlparameter("@productid", sqldbtype.varchar, 200));
      cmd.parameters["@productid"].value = request["productid"].tostring();
      this.datagrid1.datasource = cmd.executereader(commandbehavior.closeconnection);
      this.datagrid1.databind();
    }  

    protected sqlconnection con(system.string connectionstring )
    {

      sqlconnection c = new sqlconnection( connectionstring );
      c.open();  
      return c;

    }

    #endregion

    #region web form designer generated code

    override protected void oninit(eventargs e)
    {

      initializecomponent();
      base.oninit(e);

    }

    private void initializecomponent()
    {  

      this.load += new system.eventhandler(this.page_load);

    }

    #endregion

  }
}  
webform2.aspx is also quite simple. the only object that resides on the page is a datagrid which is bound to a sqldatareader. the reader gets the data for the product based on the query string parameter of the productid value. let's quickly look at the css (cascading style sheet) file and then below that contains a figure illustrating webform1.aspx when it is first rendered:  
stylesheet1.css  
/* style sheet */
body
{
margin-left: 0;
margin-top:10;
}
.headerstyle
{
background-color: #3a6ea5;
color: #ffffff;
font-weight:bold;
}

.itemstyledefault
{
background-color: #c0c0c0;
color: #000000;
font-weight: bold;
}

.itemstylehyperlink {
background-color: #c0c0c0;
color: #000000;
font-weight: bold;
}

a:link
{
color: #000000;
}

a:visited
{
color: #000000;
}

a:hover
{
color: #3a6ea5;
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
伊人成人开心激情综合网| 夜夜躁日日躁狠狠久久88av| 国产欧美精品一区二区三区介绍| 51午夜精品视频| 亚洲最大的成人网| 久久亚洲精品毛片| 欧美在线观看www| 欧美亚洲国产视频小说| 国内精品一区二区三区| 日韩精品中文字幕在线| 国产精品成人在线| 成人精品久久av网站| 欧美性猛交xxxxx水多| 国内精品久久久久影院优| 国产精彩精品视频| 国产精品91久久久| 亚洲精品久久久久久久久久久| 91香蕉嫩草神马影院在线观看| 日韩av影片在线观看| 伦伦影院午夜日韩欧美限制| 色综合视频一区中文字幕| 亚洲精品mp4| 亚洲国产精品99| 成人黄色av免费在线观看| 国产亚洲精品久久久久动| 欧美在线中文字幕| 亚洲欧美日韩另类| 国内久久久精品| 亚洲一区二区中文字幕| 国产成人免费av| 亚洲免费精彩视频| 日韩电影第一页| 国产一级揄自揄精品视频| 97人人模人人爽人人喊中文字| 亚洲美女性视频| 久久亚洲欧美日韩精品专区| 久久激情视频免费观看| 最新69国产成人精品视频免费| 欧美专区在线视频| 亚洲精品成人久久久| 亚洲а∨天堂久久精品9966| 日韩久久免费电影| 欧美视频在线免费看| 国产在线999| 久久综合网hezyo| 亚洲电影免费观看高清完整版在线| 亚洲直播在线一区| 97国产一区二区精品久久呦| 91国产精品电影| 欧美日韩国产精品一区二区不卡中文| 国产香蕉精品视频一区二区三区| 免费不卡欧美自拍视频| 国产精品久久久久影院日本| 日韩av网址在线| 精品久久久久久久久久国产| 久久久91精品国产一区不卡| 亚洲va国产va天堂va久久| 久久综合国产精品台湾中文娱乐网| 欧日韩不卡在线视频| 伦伦影院午夜日韩欧美限制| 久久久人成影片一区二区三区| 欧美激情免费在线| 成人天堂噜噜噜| 亚洲国产成人爱av在线播放| 国产手机视频精品| 亚洲精品久久久久久久久久久久久| 国产成人精品综合| 日本成人在线视频网址| 视频在线观看一区二区| 色偷偷av一区二区三区乱| 欧洲精品在线视频| 88xx成人精品| 在线观看亚洲区| 韩日精品中文字幕| 青青a在线精品免费观看| 日韩美女在线观看一区| 欧美日韩aaaa| 热久久免费国产视频| 68精品久久久久久欧美| 国产91精品青草社区| 国产精品三级久久久久久电影| 亚洲精品电影网站| 一区二区三区回区在观看免费视频| 欧美日韩性生活视频| 亚洲少妇激情视频| 亚洲视频视频在线| 欧美日韩午夜激情| 欧美劲爆第一页| 91精品一区二区| 亚洲第一在线视频| 亚洲天堂av网| 欧美激情视频三区| 欧美激情国内偷拍| 亚洲第一色中文字幕| 91精品国产色综合久久不卡98| 亚洲日本成人网| 欧美另类老肥妇| 久久久www成人免费精品张筱雨| 亚洲第一页中文字幕| 国产免费观看久久黄| 亚洲免费一级电影| 国模精品一区二区三区色天香| 国产精品美女在线| 91精品在线国产| 1769国内精品视频在线播放| 欧美激情视频给我| 欧美日本啪啪无遮挡网站| 亚洲日韩欧美视频| 亚洲精品www久久久| 国内伊人久久久久久网站视频| 亚洲一区美女视频在线观看免费| 国产有码在线一区二区视频| 久久精品色欧美aⅴ一区二区| 欧美激情视频在线| 深夜成人在线观看| 美女久久久久久久| 国产成人精品久久二区二区| 欧美大片网站在线观看| 国产精品九九九| 欧美午夜精品伦理| 日本亚洲欧美成人| 亚洲国产精品悠悠久久琪琪| 亚洲少妇中文在线| 91久久精品久久国产性色也91| 欧美成人免费全部观看天天性色| 久久精品中文字幕一区| 国产精品日韩欧美综合| 色综合老司机第九色激情| 在线观看日韩欧美| 日本国产精品视频| 欧美亚洲午夜视频在线观看| 久久影院在线观看| 亚洲精品国产成人| 日韩欧美精品网址| 国产欧美日韩精品丝袜高跟鞋| 欧美在线观看一区二区三区| 久久精品最新地址| 欧美激情亚洲激情| 97超级碰碰碰久久久| 色婷婷综合久久久久中文字幕1| 久久久久999| 懂色aⅴ精品一区二区三区蜜月| 91网站在线免费观看| 久久精品国产精品亚洲| 日韩在线观看av| 亚洲精品wwww| 久久精品男人天堂| 国产日韩精品在线播放| 亚洲欧美日韩网| 色777狠狠综合秋免鲁丝| 91av在线看| 国产成人在线精品| 亚洲开心激情网| 黑人巨大精品欧美一区二区| 久久综合88中文色鬼| 亚洲精品色婷婷福利天堂| 国产亚洲欧洲高清| 91麻豆桃色免费看| 97精品欧美一区二区三区| 亚洲免费一级电影| 美女视频久久黄| 成人国产在线激情| 国产精品久久久久久网站| 国产精品一区二区av影院萌芽|