单击gridview行以打开新窗口 [英] Click gridview row to open a new window

查看:97
本文介绍了单击gridview行以打开新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我使用下面的代码,目的是每当用户点击gridview中的列Name行时打开一个新窗口。但是,我无法使代码工作,在客户端,点击功能处于非活动状态。



< script type =   text / javascript> 

function popItUp(querystring){
window .open( ' About.aspx' + querystring);
}
< / script>





 <   asp:GridView     ID   =  gv    runat   =  server    AutoGenerateColumns   =  False  
< span class =code-attribute> DataSourceID = SqlDataSource2 OnRowDataBound = gv_RowDataBound >
< >
< asp:BoundField DataField = 名称 HeaderText = 名称 SortExpression = 名称 / >
< asp:BoundField DataField = column1 HeaderText = column1
SortExpression = column1 / >
< asp:BoundField DataField = priceTalk HeaderText = priceTalk
SortExpression = priceTalk / >
< asp:BoundField DataField = Decimal_price
HeaderText = Decimal_price < span class =code-attribute>
< span class =code-attribute> SortExpression = Decimal_price / >
< asp:BoundField DataField = 封面 HeaderText = 封面 SortExpression = 封面 / >
< asp:BoundField DataField = 输入 HeaderText = 输入 SortExpression = 输入 / >
< asp:BoundField DataField = UploadDate HeaderText = UploadDate
SortExpression = UploadDate < span class =code-attribute> / >
< /列 >
< / asp:GridView >





更新的工作解决方案:

 <   asp:TemplateField     HeaderText   =  Deal_Name >  
< ItemTemplate >
< a href = java<! - no - > script:popup('About.aspx?id = <% #Eval( Deal_name)%>& names = <% #Eval( Deal_name)%>& a = d') > <% #Eval( Deal_name)%> < / a >
< / ItemTemplate >
< / asp:TemplateField >





  function  popup(url){

popupWindow = window .open(url) ,' popupWindow'' heigh = 700,width = 900,left = 10,top = 10,resizable = yes,scrollbars = yes,toolbar = yes ,menubar = no,location = no,direction = no,status = yes'
}





任何帮助,将不胜感激。

非常感谢您的时间和帮助。

解决方案

您可以将Bound字段更改为模板化字段,而不是使用on RowDataBound下面。



 <   asp:TemplateField     HeaderText   =  开始日期    SortExpression   =  startdate >  

< ItemTemplate >

< asp:超链接 runat = server id = HyperLink1 navigateurl = <% Events.aspx?myDate = + Eval( startdate%> text = <% #Eval( startdate {0:d}%> xmlns:asp = #unknown > < / asp:hyperlink >

< / ItemTemplate >

< / asp:TemplateField >


hi


使用此行..





 e .Row.Attributes [  ondblclick] =  string .Format(  popItUp('{0}'),queryString); 





add 单引号 popItUp 函数参数


访问这里....



http://littleprograming.blogspot.com/2012/07/aspnet-gridview-row-click-open-new.html [ ^ ]

Hello,

I am using the following code below, which aims to open a new window whenever the user clicks on column Name rows in the gridview. However, I can not get the code to work and on the client-side, the click functionality is inactive.

<script type="text/javascript">

    function popItUp(querystring) {
        window.open('About.aspx' + querystring);
    }
</script>



<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False"
       DataSourceID="SqlDataSource2"  OnRowDataBound="gv_RowDataBound">
       <Columns>
           <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
           <asp:BoundField DataField="column1" HeaderText="column1"
               SortExpression="column1" />
           <asp:BoundField DataField="priceTalk" HeaderText="priceTalk"
               SortExpression="priceTalk" />
           <asp:BoundField DataField="Decimal_price" HeaderText="Decimal_price"
               SortExpression="Decimal_price" />
           <asp:BoundField DataField="Cover" HeaderText="Cover" SortExpression="Cover" />
           <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
           <asp:BoundField DataField="UploadDate" HeaderText="UploadDate"
               SortExpression="UploadDate" />
       </Columns>
   </asp:GridView>



Updated working solution:

<asp:TemplateField HeaderText="Deal_Name">
                           <ItemTemplate>
                           <a href="java<!-- no -->script:popup('About.aspx?id=<%#Eval("Deal_name")%>&designation=<%#Eval("Deal_name")%>&a=d')"><%#Eval("Deal_name")%></a>
                           </ItemTemplate>
                           </asp:TemplateField>



function popup(url) {

        popupWindow = window.open(url, 'popupWindow', 'heigh=700,width=900,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,direction=no,status=yes')
    }



Any help would be appreciated.
Many thanks for your time and help.

解决方案

instead of using the on RowDataBound you could change the Bound field to a templated field like below.

<asp:TemplateField HeaderText="Start Date" SortExpression="startdate">

<ItemTemplate>

<asp:hyperlink runat="server" id="HyperLink1" navigateurl="<%# "Events.aspx?myDate=" + Eval("startdate")%>" text="<%# Eval("startdate","{0:d}")%>" xmlns:asp="#unknown"></asp:hyperlink>

</ItemTemplate>

</asp:TemplateField>


hi
use this line..


e.Row.Attributes["ondblclick"] = string.Format("popItUp('{0}')", queryString);



add single quotes to the popItUp function parameter.


visit here....

http://littleprograming.blogspot.com/2012/07/aspnet-gridview-row-click-open-new.html[^]


这篇关于单击gridview行以打开新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆