/// <summary> /// /// </summary> /// <param name="e"></param> protected override void OnInit(EventArgs e) { lblAllowableSize.Text = string.Format("You can upload a maximum size of {0} KB", GetMaxRequestLength()); // reverse lookup the item code by the id, if specified int counter = CommonLogic.QueryStringUSInt("id"); string itemCode = string.Empty; string itemName = string.Empty; if (counter > 0) { using (SqlConnection con = DB.NewSqlConnection()) { con.Open(); using (IDataReader reader = DB.GetRSFormat(con, "SELECT ItemCode, ItemName FROM InventoryItem with (NOLOCK) WHERE Counter = {0}", counter)) { if (reader.Read()) { itemCode = DB.RSField(reader, "ItemCode"); itemName = DB.RSField(reader, "ItemName"); } } } } lblItemCode.Text = itemCode; lblItemName.Text = itemName; Title = string.Format("Upload file for {0}", itemName); // info if (counter > 0) { DownloadableItem download = DownloadableItem.FindByItemCode(itemCode); DisplayDownloadInfo(download); } else { pnlInfo.Visible = false; } base.OnInit(e); }
protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e) { if (DataControlRowType.DataRow == e.Row.RowType) { // check if the download id is null DbDataRecord currentRow = e.Row.DataItem as DbDataRecord; if (null != currentRow) { int counter = (int)currentRow["Counter"]; string itemCode = (string)currentRow["ItemCode"]; // File Name Cell DataControlFieldCell fileNameCell = e.Row.Controls[0] as DataControlFieldCell; string fileNameText = string.Empty; if (currentRow["FileName"] == DBNull.Value || currentRow["FileName"] is string && string.IsNullOrEmpty((string)currentRow["FileName"])) { fileNameText = "[UnAssigned]"; } else { fileNameText = Security.HtmlEncode((string)currentRow["FileName"]); } fileNameCell.Text = fileNameText; //Description DataControlFieldCell descriptionCell = e.Row.Controls[3] as DataControlFieldCell; string descriptionText = string.Empty; if (currentRow["WebDescription"] == DBNull.Value || currentRow["WebDescription"] is string && string.IsNullOrEmpty((string)currentRow["WebDescription"])) { descriptionText = (string)currentRow["ItemDescription"]; } else { descriptionText = (string)currentRow["WebDescription"]; } descriptionCell.Text = Security.HtmlEncode(descriptionText); // DownloadId Cell DataControlFieldCell downloadCell = e.Row.Controls[4] as DataControlFieldCell; string downloadText = string.Empty; if (currentRow["DownloadId"] == DBNull.Value || currentRow["DownloadId"] is string && string.IsNullOrEmpty((string)currentRow["DownloadId"])) { downloadText = "Upload file"; } else { downloadText = (string)currentRow["DownloadId"]; } downloadCell.Text = string.Format("<a href=\"DownloadableItem.aspx?id={0}\">{1}</a>", counter, Security.HtmlEncode(downloadText)); // Status Cell DataControlFieldCell statusCell = e.Row.Controls[6] as DataControlFieldCell; DownloadableItem download = DownloadableItem.FindByItemCode(itemCode); string statusText = string.Empty; if (null == download) { statusText = "N/A"; } else if (download.IsPhysicalFileExisting()) { if (currentRow["IsActive"] == DBNull.Value) { statusText = "N/A"; } else if (currentRow["IsActive"] is bool) { statusText = CommonLogic.IIF((bool)currentRow["IsActive"], "A", "I"); } else { statusText = "?"; } } else { statusText = "?"; } statusCell.Text = Security.HtmlEncode(statusText); } } }