开发者

Get the this object using eval in a gridview in asp

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜