This repository has been archived by the owner on Dec 29, 2023. It is now read-only.
/
Default.aspx.cs
67 lines (63 loc) · 2.36 KB
/
Default.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace DynamicShowHideTemplate {
public partial class _Default : System.Web.UI.Page {
private DataTable CreateGridData() {
DataTable table = new DataTable();
table.Columns.Add("id", typeof(int));
table.Columns.Add("Status", typeof(string));
table.Rows.Add(1, "im");
table.Rows.Add(2, "fr");
return table;
}
protected void Page_Init(object sender, EventArgs e) {
gvTrackingNumbers.DataSource = CreateGridData();
}
protected void Page_Load(object sender, EventArgs e) {
gvTrackingNumbers.DataBind();
}
// hide custom command button
protected void gvTrackingNumbers_HtmlCommandCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableCommandCellEventArgs e) {
if(e.CommandCellType == DevExpress.Web.GridViewTableCommandCellType.Data
&& e.CommandColumn.Name == "colManage") {
bool isVisible = GetManageButtonVisible(e.VisibleIndex);
e.Cell.Controls[0].Visible = isVisible;
}
}
// hide template controls
protected bool GetIssueLinkVisible(int rowVisibleIndex) {
string status = GetStatus(rowVisibleIndex);
if(status.Contains("i")) // some logic for visibility calculation
return true;
else
return false;
}
protected bool GetReturnLinkVisible(int rowVisibleIndex) {
string status = GetStatus(rowVisibleIndex);
if(status.Contains("r"))
return true;
else
return false;
}
protected bool GetManageButtonVisible(int rowVisibleIndex) {
string status = GetStatus(rowVisibleIndex);
if(status.Contains("m"))
return true;
else
return false;
}
// get cell value
private string GetStatus(int rowVisibleIndex) {
DataRow row = gvTrackingNumbers.GetDataRow(rowVisibleIndex);
return (string)row["Status"];
}
}
}