Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GridView and Eval

I am trying to pass a value through Eval in my GridView, but instead of passing the actual value, it passes the string '<%# Eval etc...This is my code, can anybody advise?

enter code here<asp:TemplateField>
            <ItemTemplate>
                <asp:Button ID="btnUpload" OnClientClick="loadDialog('<%# Eval(PK_SpecialEvent).ToString() %>') " Text="Upload/Open Files" runat="server"  />
            </ItemTemplate>
        </asp:TemplateField>
like image 664
user517406 Avatar asked Nov 30 '25 13:11

user517406


1 Answers

Try this:

OnClientClick='<%# Eval("PK_SpecialEvent", "loadDialog(\"{0}\");") %>'

Another, more readable, way is to do this in codebehind. A good place would be in GridView's RowDataBound Event.

like image 123
Tim Schmelter Avatar answered Dec 02 '25 03:12

Tim Schmelter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!