自定义中继器中数据源的输出?
我有一个连接到数据源(数据表对象)的数据转发器。我需要在某些条件下更改某些列的前端输出。做到这一点最有效的方法是什么?
我目前正在尝试创建格式化输出并将其分配给另一个数据表并将其用作数据源,但它似乎过于复杂并且难以维护。
是否有更简单的方法来操作数据源的列值?我需要能够检查源的上一行和下一行,因为这是某些列值的基础。
I have a Data Repeater hooked up to a datasource (datatable object). I need to change the output on the frontend for certain columns under certain conditions. What would be the most efficient way to do this?
I am currently trying to create the formatted output and assign it to another datatable and use that as the data source, but it seems overly complicated and something that would be hard to maintain.
Is there an easier way to manipulate column values for a datasource? I need the ability to check the previous and next rows for the source as that is a basis for some of the column values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在谈论简单的操作,则
DataBinder.Eval
方法接受格式字符串:如果格式字符串不够,您可以在代码隐藏中创建一个方法来处理格式设置,例如this:
在代码隐藏中:
您还可以使用
ItemDataBound
事件。使用此技术,如果您的操作涉及绑定到转发器的其他数据,您仍然可以访问数据源对象。If you're talking about simple manipulation, the
DataBinder.Eval
method accepts a format string:If the format string is not sufficient, you could create a method in the code-behind to handle the formatting, like this:
In code-behind:
You can also use the
ItemDataBound
event too. Using this technique, you can still access the datasource object, in the case that your manipulation involves other data that is bound to the repeater.我认为没有一种方法可以在客户端轻松地完成您想要的事情,而无需像您现在所做的那样使用特殊逻辑。如果您从数据库获取数据,您可能会在数据库端执行所有数据操作并将其透明地传递到前端。
I don't think there's a way to do what you want on the client side easily w/o using special logic like you are doing now. If you are getting data from a database, you could potentially do all the data manipulation on the DB side and pass it along transparently to the front end.