开发者

GridView and Eval

开发者 https://www.devze.com 2023-03-05 04:36 出处:网络
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?

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="btnUplo开发者_运维问答ad" OnClientClick="loadDialog('<%# Eval(PK_SpecialEvent).ToString() %>') " Text="Upload/Open Files" runat="server"  />
            </ItemTemplate>
        </asp:TemplateField>


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.


I've only done a GridView once before in my so-far beginners experience of ASP.NET, but should the:-

Eval(PK_SpecialEvent).ToString()

have quotes added in to become like:

Eval("PK_SpecialEvent").ToString()

At least - it does in my working code of a GridView.

0

精彩评论

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