happysmile
happysmile

Reputation: 7777

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

in my gridview item template filed i am calling an method CheckValue

           <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

Upvotes: 1

Views: 1363

Answers (1)

Kurt S
Kurt S

Reputation: 21357

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.

Upvotes: 4

Related Questions