开发者

Get the this object using eval in a gridview in asp

开发者 https://www.devze.com 2023-03-19 22:10 出处:网络
I can\'t find any answer anywhere. I want to refer to the row object itself in an databinding expression in a gridview, like this:

I can't find any answer anywhere. I want to refer to the row object itself in an databinding expression in a gridview, like this:

<asp:TemplateField HeaderText="Description">
    <ItemTemplate>
        <asp:Label runat="server" 
                   Text = '<%# GetPendingReason(Eval("this")) %>' />                                    
    </ItemTemplate>
</asp:TemplateField>

But it doesn't work beca开发者_高级运维use "this" doesn't refer to any attribute. Referencing individual attributes works fine, but how do you refer to the current row?


Simply use <%# Container.DataItem %>. Do not use Databinder.


If you want to refer to the current row you do that at codebehind using

GridViewRow row = GridView1.Rows[index];
at any of the GridView event.

0

精彩评论

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