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 Maciej Los 589
1 OriginalGriff 379
2 CPallini 205
3 RyanDev 175
4 Sergey Alexandrovich Kryukov 160
0 OriginalGriff 5,689
1 Sergey Alexandrovich Kryukov 4,783
2 Peter Leow 2,954
3 Maciej Los 2,819
4 DamithSL 2,465


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