GridView项目模板中的div [英] div inside a gridview itemtemplate

查看:69
本文介绍了GridView项目模板中的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在gridview的itemtemplate单​​元内创建和控制div的内容?

How do I create and control the content of a div inside a cell of an itemtemplate in a gridview?

谢谢.

推荐答案

给出div和id并运行runat ="server",然后使用rowdatabound事件

Give your div and id and runat="server" then use the rowdatabound event

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

然后,您需要根据ID在每一行中找到div并进行所需的任何更改

You'll then need to find your div within each row based on the id and make whatever changes you need

哦,别忘了在rowdatabound事件中使用它,否则您将抢到页眉,页脚等,而无法在其中找到控件

Oh and don't forget to use this within your rowdatabound event or you'll grab headers, footers, etc and not be able to find your control in there

if(e.Row.RowType == DataControlRowType.DataRow)

这篇关于GridView项目模板中的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆