Click here to Skip to main content
15,941,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
--scenario
C#
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.
Posted

Hey there,

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

ASP.NET
<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....
 
Share this answer
 
Comments
anurag19289 15-Oct-13 6:58am    
This seems interesting. I will try and get back to you
Why? What's wrong with RowDataBound event? Anyways, you may try the following JQuery code.
JavaScript
var table = $("#IdOfTableCreatedDynamically table");
table.find('tr').each(function (i, el) {//"i" is the index of element and "el" is the element.
var $tds = $(this).find('td'),
addressIdOne = $tds.eq(0).text(),
addressIdTwo = $tds.eq(1).text();
//You will have to handle click of linkbutton here with the required parameters. 
});


You will have to make few changes to the above code and test. Check if it suits you.
 
Share this answer
 
v2
Comments
anurag19289 15-Oct-13 7:51am    
Hi Zafar-

I will try this and revert you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900