开发者

how to send parameter from.aspx page to.cs file[in #eval method in gridview]

开发者 https://www.devze.com 2022-12-15 20:08 出处:网络
in my gridview item template filed i am calling an methodCheckVa开发者_如何学Clue <asp:Label ID=\"Label1\" runat=\"server\" Text=\'<%# CheckValue(Eval(\"Imagespath\")+\",\"+Eval(\"Imagesname\")

in my gridview item template filed i am calling an method CheckVa开发者_如何学Clue

           <asp:Label ID="Label1" runat="server" Text='<%# CheckValue(Eval("Imagespath")+","+Eval("Imagesname")%>'>
            </asp:Label>


protected string CheckValue(string strValue1,string strValue2)
    {
        if (strValue1=="1")
        {
            return "No Record Found";
        }
        else
        {
            return "No Record Found";
        }
    }

when i run my page i get errorin my .aspx page

Text='<%# CheckValue(Eval("Imagespath")+","+Eval("Imagesname")%>'>

is there any way i can send my value CheckValue method which isa .cs file how can i send 2 paremeter from.aspx page can anu one tell me the syntax for it

thank you


You are almost there... try this:

Text='<%# CheckValue(Eval("Imagespath").ToString(), Eval("Imagesname").ToString()) %>'

You don't need to add the +","+ as if you were concatenating a string (you aren't), and you do need to call ToString() on the Evals so it matches the parameter types your CheckValue method expects.

0

精彩评论

暂无评论...
验证码 换一张
取 消