| Author: Arti 04 Oct 2008 | Member Level: Silver | Rating:    Points: 6 |
you can define method by passing gridname and bind it in the method itsef & can call from 2 pages.
public static void bingGridView(System.Web.UI.WebControls.GridView grdVw, string sql) { string ClassCon = ClassConnection.GetConnectionString(); using (SqlConnection con = new SqlConnection(ClassCon)) { con.Open(); SqlCommand cmd = new SqlCommand(sql, con); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(dt); if (dt.Rows.Count > 0) { grdVw.DataSource = dt; grdVw.DataBind(); } } }
|