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

Wednesday, July 28, 2010

Bind GridView Common Function

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Master"].ConnectionString);
SqlTransaction tran=null ;
SqlCommand cmd;
SqlDataAdapter adp;
DataSet ds;

public void BindGridview(GridView gr, string table, string sorting)
{
adp = new SqlDataAdapter("Select * from " + table + " order by " + sorting ,con );
ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
gr.DataSource = ds.Tables[0];
gr.DataBind();
}
else
{ //Empty grid view
}

}

No comments:

Post a Comment