Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hello all,
 
Would appreciate if anyone could help me.
 
I have two columns in my gridview, 1st column is a templatefield for capturing rownumber of grid and 2nd column is a link button clicking on which i am opening a pop up window.
<columns>
    <asp:TemplateField HeaderText="RowNum" Visible="false"> 
    <itemtemplate> 
    <asp:Label ID="lblRowNum" runat="server" Text="<%#Container.
    DataItemIndex + 1>">
    </itemtemplate> 
 
    <asp:TemplateField HeaderText="FileName"> 
    <itemtemplate>
    <asp:LinkButton ID="btn"  runat="server" Text='<%#Eval("Empid")%>'
    CommandName="Click" OnClientClick='<%# Eval("FileName", "window.open
    (\"abc.aspx\",null,\"location=0,status=0,toolbar=0,
    menubar=0,resizable=1\",\"true\");")%>'/>
    </itemtemplate>
This works fine however i want to pass text of label(from first column) as querystring of popup window.
 
Could it be done in codebehind or within window.open of my javascript code which i am calling onclick event of link button.
 
Thanks in advance
Posted 5-Oct-12 2:38am
Edited 5-Oct-12 3:47am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This can be done in codebehind the ItemDataBound event.
LinkButton lb = dataItem.FindControl("btn") as LinkButton;
string qString = "abc.aspx?value=" + lb.Text;
 lb.OnClientClick = "window.open
    ('"+qString +"',null,"location=0,status=0,toolbar=0,
    menubar=0,resizable=1","true");
";
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 490
1 Gihan Liyanage 338
2 ChauhanAjay 180
3 Vinay Mistry 160
4 Sergey Alexandrovich Kryukov 153
0 Sergey Alexandrovich Kryukov 9,011
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100