0

So I have this application where I'm trying to create a notification panel which will display some data (which will be handled by a datasource based on an object) in a datarepeater. However some of these notifications need to behave different than others. For example a missed message notification needs 3 buttons (ignore,respond,delete) while a software version notification would only need 2 (ignore,delete). Is there any way to do this with the datarepeater or should I just create a different datasource and datarepeater for each type of notification

Vishvadeep singh
  • 1,624
  • 1
  • 19
  • 31

1 Answers1

0

I have a data repeater and use the data binding event (Button1_DataBinding) and then use:

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

to get to the gridview row, you can then expand that to look at the datarow in question:

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

I can then set the visible property for the button based on any field or combination of from the bound data, example:

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

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

((Button)sender).Visible = false;

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

sure there is a more efficient way but it works

JustLearning
  • 3,164
  • 3
  • 35
  • 52