public ApiMembership(DataRow dataRow) { this.name = dataRow["Name"].ToString(); this.color = dataRow["Color"].ToString(); this.properties = new List <KeyValuePair <string, string> >(); var hiddenProperties = MembershipProperty.GetPropsToHideForClient(); var columnNames = dataRow.Table.Columns.Cast <DataColumn>() .Select(x => new KeyValuePair <string, int>(x.ColumnName, x.Ordinal)).ToList(); foreach (var columnName in columnNames) { if (columnName.Key != "Name" && columnName.Key != "Color" && !hiddenProperties.Contains(columnName.Key)) { properties.Add( new KeyValuePair <string, string>(MembershipProperty.GetResourceLabel(columnName.Key), MembershipProperty.Format(columnName.Value, dataRow[columnName.Key].ToString(), false)) ); } } }
protected void UpgradeGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //Create an instance of the datarow var rowData = e.Row.Cells[1].Text; //Set proper width //e.Row.Cells[0].ControlStyle.Width = Unit.Pixel(230); foreach (TableCell tc in e.Row.Cells) { if (tc != e.Row.Cells[0]) { //tc.ControlStyle.Width = Unit.Pixel(50); tc.ControlStyle.CssClass = "text-center"; } } if (hiddenProperties.Any(p => p == e.Row.Cells[0].Text)) { e.Row.CssClass = "displaynone"; } //Add image to index 1 (name) if (e.Row.RowIndex == 1) { int indexOfUpgrade = 0; foreach (TableCell tc in e.Row.Cells) { if (tc != e.Row.Cells[0]) { string upgradeName = tc.Text; string imageName = "standardbox"; if (upgradeName != Membership.Standard.Name) { //Because max premiumimagename is 7 //I know it is shitty work imageName = (indexOfUpgrade > 7) ? "premiumbox7" : "premiumbox" + indexOfUpgrade.ToString(); } tc.Text = "<div class=\"text-center\"><p><strong>" + upgradeName + "</strong></p><img src=\"Images/OneSite/Upgrade/" + imageName + ".png\" /></div>"; indexOfUpgrade++; } } } e.Row.Cells[0].Text = MembershipProperty.GetResourceLabel(e.Row.Cells[0].Text); foreach (TableCell tc in e.Row.Cells) { if (tc != e.Row.Cells[0]) { tc.Text = MembershipProperty.Format(e.Row.RowIndex, tc.Text); } } //Add color if (e.Row.RowIndex == 12) { foreach (TableCell tc in e.Row.Cells) { if (tc != e.Row.Cells[0]) { tc.Text = "<div class=\"upgrade-table-label\" style=\"background-color:" + tc.Text + ";\"> </div>"; } } } //Hide AutoPay price if no autopay if (e.Row.RowIndex == 15) { foreach (TableCell tc in e.Row.Cells) { if (tc != e.Row.Cells[0] && tc.Text.Contains("$0.000")) { tc.Text = " "; } } } } else if (e.Row.RowType == DataControlRowType.Header) { foreach (TableCell tc in e.Row.Cells) { tc.Text = " "; } } }