Using Session in asp.net :
string strName = "Raghava";
if (Session["tName"] == null)
 Session["tName"] = strName; 
   strName = Session["tName"].ToString(); 
txtName.Text= strName;

Using Data Cache in asp.net :

string strName = "Rajesh";
if (Cache["tName"] == null)
 Cache["tName"] = strName; 
   strName= Cache["tName"].ToString(); 
txtName.Text= strName;

Using Data ViewState in asp.net :

View state maintains the current state of the page,during postbacks
string strview = "Rajesh";
if (ViewState["viewName"] == null)
 ViewState["viewName"] = strview ; 
   strview = ViewState["viewName"].ToString(); 
txtName.Text= strview ;

Using Javascript from codebehind in asp.net :

example : This example is for showing alert.

string msgAlerta = "Session has been expire, Please login again to continue";
string alertMsga = "<script language=javascript>alert('" + msgAlerta + "');";
alertMsga += "window.location='../login.aspx'</script>";
Page.RegisterClientScriptBlock("alertMsga", alertMsga);

Row Databound in Gridview in asp.net

protected void grvflat_RowDataBound(object sender, GridViewRowEventArgs e)
  if (e.Row.RowType == DataControlRowType.DataRow)
    DataRow dr = ((DataRowView)e.Row.DataItem).Row;
    string SFT = (dr["SFT"].ToString());
    string flaname = (dr["Flatno"].ToString());
    string phno=(dr["phoneno"].ToString());
    string cid=(dr["cid"].ToString());
    string fname = (dr["customername"].ToString());
    ((HyperLink)e.Row.FindControl("hlinkforbook")).Text = "SelectforBook";
    string url = string.Format("~/ApllicationFormSTL.aspx?flatname=" + flaname     +   "&&SFT=" + SFT+"&&phoneno="+phno+"&cid="+cid+"&&cname="+uname);

            ((HyperLink)e.Row.FindControl("Hyperlinkavail")).NavigateUrl = url;

Remove The Session in asp.net :

Example for Gridview in asp.net  :

 <asp:GridView ID="grvExample" runat="server" AutoGenerateColumns="False">
      <asp:TemplateField HeaderText="CustomerName">
           <asp:Label ID="clabe" runat="server" Text='<%#Eval("name")%>'>  </asp:Label>
                     <asp:TemplateField HeaderText="Address">
                    <asp:Label ID="caddres" runat="server" Text='<%#Eval("addres")%>'></asp:Label>
                     <asp:TemplateField HeaderText="CustomerPhoneno">
                    <asp:Label ID="phlabel" runat="server" Text='<%#Eval("phoneno")%>'></asp:Label>
                    <asp:TemplateField HeaderText="TeamLeadComments">
                    <asp:Label ID="temcomments" runat="server" Text='<%#Eval("temcomments")%>'></asp:Label>
                    <asp:TemplateField HeaderText="Assign">
                    <asp:LinkButton ID="linkassign" runat="server" Text= "ReAssign" CommandArgument='<%#Eval("custid")%>' CommandName="Assign"></asp:LinkButton>

Get & Set the querystring values in asp.net :

Set :
Response.Redirect("test.aspx? phoneno='43434344'&mail='ex@abc.com'&name='abc' ")

phno = Request.QueryString["phoneno"].ToString();
Emailid = Request.QueryString["mail"].ToString();

Calculate Percentages in asp.net :
txtfirsttot.Text = txtdsctot.Text;
float salesconsider = float.Parse(txtdsctot.Text);
int dob45 = 15;
float ondate45 = salesconsider * dob45 / 100;
txtdob45.Text= ondate45.ToString();    

Convert the date format into dd/mm/yyyy :

string strDate = DateTime.Now.ToString("dd/MM/yyyy");

AjaxAutoComplete Extendar in asp.net :

   <asp:TextBox ID="txttestajax" runat="server"  ></asp:TextBox>
                                      DelimiterCharacters=";, :"
                                      MinimumPrefixLength="2" ServiceMethod="GetCompletionList3"
                            <%-- Make the completion list transparent and then show it --%>
                            <OpacityAction Opacity="0" />
                            <HideAction Visible="true" />                           
                            <%--Cache the original size of the completion list the first time
                                the animation is played and then set it to zero --%>                   
                        <ScriptAction Script="
                                // Cache the size and setup the initial size
                                var behavior = $find('AutoCompleteEx');
                                if (!behavior._height) {
                                    var target = behavior.get_completionList();
                                    behavior._height = target.offsetHeight - 2;
                                    target.style.height = '0px';
                                }" />
                            <%-- Expand from 0px to the appropriate size while fading in --%>
                                  <Parallel Duration=".4">
                                <FadeIn />
                                <Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
                                     <Parallel Duration=".4">
                               <FadeOut />
                               <Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />

Sending Mail using asp.net  with attachments:

using System.Net.Mail;
MailMessage mm = new MailMessage (string from, string to);
mm.Subject = "Mail from Cybercity";
mm.Body = TextBox10.Text;
mm.IsBodyHtml = true; 
mm.Attachments.Add(new Attachment(Server.MapPath("~//Brochure//layout.jpg")));
SmtpClient sClient = new SmtpClient();
sClient.EnableSsl = true;

sClient.Timeout = 400000;

AutoIncrement Id in DataTable:
DataTable dtIsolate=new DataTable();
dtIsolate.Columns.Add("EqID", typeof(int)); 
dtIsolate.Columns["EqID"].AutoIncrementSeed = 1; 
dtIsolate.Columns.Add("Equipment", typeof(string));
IsolateCategory", typeof(string)); 
dtIsolate.Columns.Add("Isolated", typeof(bool));

dtIsolate.Rows.Add(dtIsolate.Rows.Count + 1,txtEq.Text, strIsolate, chkIso_action.Items[0].Selected)

Display line number in Visual Studio

Select Tools → Options → Text Editor → select the language in which you write the code → Display → Select Line Number.  
No.of visible rows with in the aspxgridview

grvCertificates.VisibleRowCount   -- -----get the no.of visible rows with in the aspxgridview 
//here grvCertificates is the devexpress gridview Id


Custom Search
Protected by Copyscape Plagiarism Software