Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
HTML
<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
Updated 5-Oct-12 3:47am
v2

1 solution

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");
";
 
Share this answer
 
v2

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