如何将gridview行的particalr值作为参数传递给javascript [英] How to pass particualr value of gridview row to javascript as parameter

查看:96
本文介绍了如何将gridview行的particalr值作为参数传递给javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- 场景

 gridview1 

addressid1 addressid2 map

12 100 linkbutton1

13 200 linkbutton2

14 300 linkbutton3



- 现在我点击链接按钮(假设linkbutton2即第二行)

13 100 应该传递 as javascipt函数的参数。

函数OpenGoogleRouteWindow(addressid1,addressid2)
{
var sFeatures = ' dialogHeight:700px; dialogWidth:1000px;';
var windowValue = window.showModalDialog(' GoogleMapRoute.aspx?ID =' + addressid1 + ' & Type =' + addressid2, ' ',sFeatures);
}







- 我不想使用gridview的rowdatabound。可以在没有rowdatabound的情况下完成吗?



- 告诉我如何将particualr行的参数传递给javascipt函数。

如果单击第3行linkutton,那么14和300将作为参数传递给函数。我可以使用该功能打开一个新窗口。

解决方案

嘿那里,



我有使用你的字段并创建了一个符合你要求的例子。



 <   asp:gridview     id   =  GridView1    runat   =  server    autogeneratecolumns   =  False    xmlns:asp   = < span class =code-keyword>#unknown >  
< >
< asp:boundfield datafield = addressid1 headertext = addressid1 / >
< asp:boundfield datafield = addressid2 headertext = addressid2 / >
< asp:templatefield headertext = map >
< itemtemplate >
< asp:linkbutton id = LnkViewMap runat = server text = < span class =code-keyword>查看地图 onclientclick = <% OpenGoogleRouteWindow( + Eval( addressid1 )+ + Eval( addressid2)+ %> > < / asp:linkbutton >
< < span class =code-leadattribute> / itemtemplate >
< / asp:templatefield >
< ; / columns >
< / asp:gridview >





如果有帮助请告诉我。



Azee ....


为什么? RowDataBound事件有什么问题?无论如何,您可以尝试以下JQuery代码。

  var  table = 


#IdOfTableCreatedDynamically table);
table.find(' tr')。each(功能(i,el){ // i是元素的索引和 el是元素。
var


--scenario

gridview1

addressid1 addressid2   map  

12          100        linkbutton1

13          200        linkbutton2

14          300        linkbutton3



--now when i click the link button (suppose linkbutton2 i.e second row)

13 and 100 should be passed as parameter to the javascipt function. 

function OpenGoogleRouteWindow(addressid1, addressid2)
 {
 var sFeatures = 'dialogHeight: 700px;dialogWidth: 1000px;';
 var windowValue = window.showModalDialog('GoogleMapRoute.aspx?ID=' + addressid1+ '&Type=' +   addressid2, '', sFeatures);
 }




--i dont want to use rowdatabound of gridview. Can it be done without rowdatabound ?

--Tell me the way how to pass the parameter of particualr row to javascipt function.
if 3rd row linkutton is clicked then 14 and 300 will be passed as parameter to the function. ANd i can use that function to open a new window.

解决方案

Hey there,

I have used your fields and created an example that meets your requirements.

<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" xmlns:asp="#unknown">
        <columns>
            <asp:boundfield datafield="addressid1" headertext="addressid1" />
            <asp:boundfield datafield="addressid2" headertext="addressid2" />
            <asp:templatefield headertext="map">
                <itemtemplate>
                    <asp:linkbutton id="LnkViewMap" runat="server" text="View Map" onclientclick="<%#"OpenGoogleRouteWindow(" + Eval("addressid1") +"," + Eval("addressid2") + ")"%>"></asp:linkbutton>
                </itemtemplate>
            </asp:templatefield>
        </columns>
    </asp:gridview>



Let me know if it helps.

Azee....


Why? What's wrong with RowDataBound event? Anyways, you may try the following JQuery code.

var table =


("#IdOfTableCreatedDynamically table"); table.find('tr').each(function (i, el) {//"i" is the index of element and "el" is the element. var


这篇关于如何将gridview行的particalr值作为参数传递给javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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