Subhash Sharma

Subhash Sharma
Subhash Sharma

This is Subhash Sharma(Software Engineer) Blog

Welcome to this blog and find every solution.............

Search This Blog

Software Engineer(Subhash Sharma)

Software Engineer(Subhash Sharma)
Software Engineer

Tuesday, February 4, 2014

Ref and Out

ref object a, out object out specifies that the parameter is an output parameters, i.e. it has no value until it is explicitly set by the method. ref specifies that the value is a reference that has a value, and whose value you can change inside the method.

Tuesday, October 1, 2013

DataTable Rows filter

DataView dv = dsDetail.Tables["Employee"].DefaultView; dv.RowFilter = "Id in(10,2,1,5,6,1)"; DataTable dt = dv.ToTable(); ((Repeater)ctrl).DataSource = dt; ((Repeater)ctrl).DataBind();

Saturday, April 23, 2011

What Happens When a Request Reaches IIS

This is the link for All the details related parsing asp.net page and generating Requst and Response


http://msdn.microsoft.com/en-us/library/ms972974.aspx

Wednesday, April 20, 2011

Disable Browser Back Button using Javascript

head runat="server">
script type="text/javascript" language="javascript">
javascript:window.history.forward(0);
/script>
/head>

Disable Browser Back Button using Javascript

head runat="server">
script type="text/javascript" language="javascript">
javascript:window.history.forward(0);
/script>
/head>

Tuesday, March 22, 2011

Microsoft Enterprises Library

Microsoft Enterprises Library provide API where we dont need to open and close connection and they have sme predefind method .You dont need to create your own method .it has pedefined method for all that things for insert update delete retrieve and some more specific operation...........

You have to download the Entterprise lIbrary first and Add some Dll through AddReferences from a bin folder of Enterprises Library add

using Microsoft.Practices.EnterpriseLibrary.Data.dll
using Microsoft.Practices.EnterpriseLibrary.Common..dll

and Add the classes in code behind

using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;


//Retrieve and Insert value Using Entrprises library

protected void Page_Load(object sender, EventArgs e)
{
Database db = DatabaseFactory.CreateDatabase();
string sqlcommand = "select * from emp";
System.Data.Common.DbCommand dbCommand = db.GetSqlStringCommand(sqlcommand);
using (IDataReader reader = db.ExecuteReader(
dbCommand))
{
Gridview1.DataSource = reader;
Gridview1.DataBind();
}
}
public void save(string name)
{
DatabaseFactory.CreateDatabase().ExecuteNonQuery("inserts12",name);
}
protected void Button1_Click(object sender, EventArgs e)
{
save("subhash");
}

/////////web.config file
inside the ConfigSection
section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,Microsoft.Practices.EnterpriseLibrary.Data" />

after closing configsection You have to add

/configSections>
dataConfiguration defaultDatabase="Master1"/>

//dataconfiguration same name as the connection string because DatabaseFactory.CreateDatabase(); using for connection

//connection string

add name="Master1" providerName="System.Data.SqlClient" connectionString="Data Source=subhash-9f7eec2;user id=;password=;database=Master;integrated security=sspi;"/>

Friday, March 18, 2011

Generic

using System.Collections.Generic;

In an Arraylist, As Each item is stored as an object, During Sorting and traversing the list, it must be typed at runtime, and then compared for sorting/searching wheareas Generic list has all items typed compile time, which saves a lot of workload during sorting and searching.

The List class is the generic equivalent of the ArrayList class. It implements the IList generic interface using an array whose size is dynamically increased as required.

Type safety : it gives error at compile time if a data type mismatch is found.

Code reusablity : Same code is reused for various data tyoe like int,string etc.

public class User
{
protected string name;
protected int age;
protected double salary;
public string Name { get { return name; } set { name = value; } }
public int Age { get { return age; } set { age = value; } }
public double Salary { get { return salary; } set { salary = value; } }

static void Main(string[] args)
{
List users = new List();

for (int x = 0; x < 5; x++)
{
User user = new User();
user.Name ="Name : "+ "subhash" + x;
user.Age = x+20;
user.salary =x + 12500;
users.Add(user);
}

foreach (User user in users)
{
System.Console.WriteLine(System.String.Format("{0}:{1}:{2}", user.Name, user.Age,user.salary));
}

Console.ReadLine();
}
}