Asp.Net Special

How to add DataColumn In Repeater Using DataTable

Add namespace
<%@ Import Namespace="System.Data" %>
<%#((DataRowView)Container.DataItem)["CustomerName"] %>

How to get Connection string from web.config

string strCon = ConfigurationManager.ConnectionStrings["ConnectionString"]

.ConnectionString;

Write Connection String in web.config

add name="ConnectionString"
connectionString="Data Source=Source Name;Initial Catalog=DataBase Name;User ID=UserID;Password=Password"
providerName="System.Data.SqlClient" 


How to create & Read or Write cookie in asp.net using c#

HttpCookie cookie;

// Save Cookie
cookie = new HttpCookie("Dates");
        cookie.Values.Add("FromDate", tbAppDateFrom.Text);
        cookie.Values.Add("ToDate", tbAppDateTo.Text);
        Response.Cookies.Add(cookie);
        cookie.Expires = DateTime.Now.AddDays(1);

// Read Cookie
private void ReadCookie()
    {
        HttpCookie cookie = Request.Cookies["Dates"];
        String strCookieValue = cookie.Value.ToString();
        string FromDate = cookie["FromDate"].ToString();
        string ToDate = cookie["ToDate"].ToString();
        tbDateFrom.Text = General.GetDateFormat(FromDate).ToString("dd/MM/yyyy");
        tbDateTo.Text = General.GetDateFormat(FromDate).AddDays(10).ToString("dd/MM/yyyy");
    } 

3 comments :