Hi,
Can anyone help me? I just want to know if it is advisable to use objects or procedural in listing all items in gridview. Example is if i want to "SELECT * FROM dogs" and put it in a gridview. Is it proper to make a method in a class or directly code it in the load event of a form?
Pardon my bad english.
Thanks guys. Hope anyone can help me.
Jirr
Loading
Krishna GaradPosted Jan 20, 2011, 4:12 AM
Public DataSet GetData()
{
SqlConnection _sqlcncn=new SqlConnection("ConnectionString);
SqlCommand sqlcmd = new SqlCommand("Select Query", sqlcn);
// sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcn.Open();
DataSet ds = new DataSet();
sqlda = new SqlDataAdapter(sqlcmd);
sqlda.Fill(ds);
return ds;
}
In code behind call this method like bello
DataSet ds=Class.GetData();
Gridview.DataSource=ds.Tables[0];
GridView.DataBind();
Jirr MeynorPosted Jan 20, 2011, 4:24 AM
Jirr MeynorPosted Jan 20, 2011, 2:48 AM
Thank you for answering that question. But I have another problem regarding that. I don't know how will I use that method and bind it in the gridview. Can you give me a simple example? Thanks again sir.
Jirr
Krishna GaradPosted Jan 20, 2011, 1:42 AM