asp.net - Pass Eval as javascript function parameter in gridview - Stack Overflow

I have the following:<EditItemTemplate><asp:Button ID="wrqst_need_ind_btn" runat=&qu

I have the following:

<EditItemTemplate>
                    <asp:Button ID="wrqst_need_ind_btn" runat="server" Text = "Create WR" 
                        onClientClick="javascript:popUp('popup_createWR.aspx')"
                        CommandArgument='<%# Eval("dvc_nm") + "|" + Eval("data_orgtn_yr") %>'/>
 </EditItemTemplate>

I want to pass in as two additional params the Eval("dvc_nm") and Eval("data_orgtn_yr") to the popup function.

how do I do this?

Thanks so much for the help!

UPDATE:

I tried the suggestion bellow, and I tried by removing the single quotes from insode the <% %> tags. Which gave me this:

onClientClick='<%# "javascript:popUp(popup_createWR.aspx," + Eval("dvc_nm") + "," + Eval("data_orgtn_yr") + ")" %>'

which plied, but when I clicked the button I did not get a pop up, the page just posted back and reloaded and said errors on page, but no popup...

I have the following:

<EditItemTemplate>
                    <asp:Button ID="wrqst_need_ind_btn" runat="server" Text = "Create WR" 
                        onClientClick="javascript:popUp('popup_createWR.aspx')"
                        CommandArgument='<%# Eval("dvc_nm") + "|" + Eval("data_orgtn_yr") %>'/>
 </EditItemTemplate>

I want to pass in as two additional params the Eval("dvc_nm") and Eval("data_orgtn_yr") to the popup function.

how do I do this?

Thanks so much for the help!

UPDATE:

I tried the suggestion bellow, and I tried by removing the single quotes from insode the <% %> tags. Which gave me this:

onClientClick='<%# "javascript:popUp(popup_createWR.aspx," + Eval("dvc_nm") + "," + Eval("data_orgtn_yr") + ")" %>'

which plied, but when I clicked the button I did not get a pop up, the page just posted back and reloaded and said errors on page, but no popup...

Share edited Jun 28, 2010 at 11:31 kralco626 asked Jun 25, 2010 at 16:26 kralco626kralco626 8,65441 gold badges115 silver badges171 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

Try this instead:

ASPX:

<asp:Button ID="wrqst_need_ind_btn" runat="server" Text="Create WR"
    onClientClick="<%# GetPopupScript() %>" />

Code-behind:

protected string GetPopupScript()
{
    return string.Format( "javascript:popUp('popup_createWR.aspx', '{0}', '{1}')", Eval( "dvc_nm" ), Eval( "data_orgtn_yr" ) );
}

This will work 100%
please follow code in following sequence

Example

 OnClientClick='<%# string.Format("javascript:return fnSelectedLocationList(\"{0},{1},{2},{3},{4}\")", Eval("Location"),Eval("Version"),Eval("Lot"),Eval("Quantity"),Eval("WKOLineNumber")) %>'

This should work

  <asp:Button ID="wrqst_need_ind_btn" runat="server" Text = "Create WR" 
                    onClientClick='<%# "javascript:popUp('popup_createWR.aspx','" + Eval("dvc_nm") + "','" + Eval("data_orgtn_yr") + "')" %>'
                    CommandArgument='<%# Eval("dvc_nm") + "|" + Eval("data_orgtn_yr") %>'/>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742296317a4417191.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信