Thursday, March 27, 2014

Formatting

asp:GridView

 <asp:BoundField DataField="DueDate" HeaderText="Date Requested" SortExpression="DueDate"  DataFormatString="{0:M/d/yyyy}"  >

  <asp:BoundField DataField="PlanAsset" HeaderText="Assets" SortExpression="PlanAsset" ItemStyle-HorizontalAlign="Right"  DataFormatString="{0:C2}"> <HeaderStyle />



***************************************************
<asp:TemplateField HeaderText="End Date">
 <ItemTemplate>
                      <asp:Label ID="lblEndDate" runat="server" Text='<%# Eval("EndDate","{0:MM/d/yyyy}") %>'>                       </asp:Label>
</ItemTemplate>
<HeaderTemplate>
           <asp:LinkButton ID="lnEndDate" runat="server" Text="End Date" OnClick="lnEndDate_Click">
             </asp:LinkButton>
  </HeaderTemplate>
     <HeaderStyle Width="12%" />
   <ItemStyle Width="12%" />

 </asp:TemplateField>
***********************************************************************



 string CensusFileUrl = null;

Session["DataItemName"].ToString();
Session["AllocationNumber"] != null
 Session["PrevccStatusID"] = null,""; 
((Label)Master.FindControl("lblMstrHead")).Text = "Retirement Solutions"; 
Session["InvestmentGroupID"] = Request.QueryString["InvestmentGroupID"];
int.Parse(Session["ProductId"].ToString())
int refId = Convert.ToInt32(Session["UserRefflId"].ToString()); 
Session["SelectedMenuName"] = "investmentPaging";

protected string SelectedMenuName         {             get             { return Session["SelectedMenuName"] != null ? Session["SelectedMenuName"].ToString() : "";            }         }
        if (resultSet.Count() != 0)
{ grdInvestment.DataSource = resultSet; grdInvestment.DataBind(); } else { this.lblMsg.Attributes.CssStyle.Add("font-size", "30px") lblMsg.Text = "Information not found"; }




        string tableName;
        if(!Page.IsPostBack)
            {            
                tableName = Request.QueryString["tableName"];
                if(!string.IsNullOrEmpty(tableName))
                {
                    this.LoadSearchDropdownList(tableName);
                }
            }

if (Request.QueryString["ProductId"] !=null )                 {                     Session["ProductId"] = Request.QueryString["ProductId"];                     Session["InvestmentGroupID"] = null;                 } 

Conditional (Ternary) Operator (?:)

condition ? first_expression : second_expression;

int input = Convert.ToInt32(Console.ReadLine());
string classify;

// if-else construction.
if (input > 0)
    classify = "positive";
else
    classify = "negative";

// ?: conditional operator.
classify = (input > 0) ? "positive" : "negative";

?? operator is called the null-coalescing operator.
The null-coalescing operator (??) is used to define a default value for a nullable type. It returns the left-hand operand if it is not null; otherwise it returns the right operand. When we work with databases, we often deal with absent values. These values come as nulls to the program. This operator is a convenient way to deal with such situations.
http://weblogs.asp.net/scottgu/archive/2007/09/20/the-new-c-null-coalescing-operator-and-using-it-with-linq.aspx

MVC
<td > @string.Format("{0:MM/dd/yyyy}", item.DOB) </td>
<td> @item.TypeName </td>
  • DateTime dtTransEffectiveDate = Convert.ToDateTime(((DataRow)drData)["TransEffectiveDate"].ToString());
  • string TransEffectiveDate = String.Format("{0:MM/dd/yyyy}", dtTransEffectiveDate); //dtTransEffectiveDate.ToString("MM/dd/yyyy");
  • form1099R.EndDate = dataRow["EndDate"] == DBNull.Value ? null : (DateTime?)dataRow["EndDate"];
  • form1099R.DateUpload = dataRow["DateUpload"] == DBNull.Value ? DateTime.Now.AddDays(-31) : (DateTime?)dataRow["DateUpload"];
  • txtPlanTax.Text = planTaxID.Substring(0, 2) + "-" + planTaxID.Substring(2, planTaxID.Length - 2);
 @if(imagePath != ""){
            <img src="@imagePath" alt="Sample Image" width="300px" />
        }








No comments:

Post a Comment