【问题标题】:Change behavior of buttons in datarepeater更改数据中继器中按钮的行为
【发布时间】:2018-10-03 10:20:34
【问题描述】:

所以我有这个应用程序,我正在尝试创建一个通知panel,它将在datarepeater 中显示一些数据(将由基于objectdatasource 处理)。然而,其中一些通知需要表现得与其他通知不同。例如,错过的消息通知需要 3 个buttons(忽略、响应、删除),而软件版本通知只需要 2 个(忽略、删除)。有什么办法可以用datarepeater 做到这一点,或者我应该为每种类型的通知创建一个不同的datasourcedatarepeater

【问题讨论】:

  • 根据您的要求显示一些东西(代码 sn-p)。

标签: c# forms datarepeater


【解决方案1】:

我有一个数据转发器并使用数据绑定事件(Button1_DataBinding) 然后使用:

((GridViewRow)((Control)sender).Parent.Parent)

要到达gridview 行,您可以将其展开以查看相关数据行:

((DataRowView)((GridViewRow)((Control)sender).Parent.Parent).DataItem)["FIELD1"]

然后我可以根据绑定数据中的任何字段或组合设置按钮的可见属性,例如:

DataRowView DRV = (DataRowView)((GridViewRow)((Control)sender).Parent.Parent).DataItem;

if (DRV["FIELD1"].ToString().Trim() == "1234567")

((Button)sender).Visible = false;

 else ((Button)sender).Visible = true;

当然有更有效的方法,但它确实有效

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-16
    • 2010-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多