R
reetu
Hi All,
I read about webcontrols and learnt how to display
controls like textbox , buttons etc on the aspx page.
I want to build a webcontrol that would display Datagrid
when placed on the form. I couldn't find a link that would
provide step by step detail on how to do this.
I tried few things and now I can see the data grid control
on the form. When I run the application the page appears
to be blank.
The code is as follows:
public class TasksPage :System.Web.UI.WebControls.DataGrid
{
DataGrid DataGrid1 = new DataGrid();
override protected void OnInit(EventArgs e)
{
// Put user code to initialize the page here
SqlConnection connection = new SqlConnection
("server=(local);database=trial;Trusted_Connection=yes");
string query = "select * from Author";
SqlDataAdapter adapter = new SqlDataAdapter
(query,connection);
DataSet dset = new DataSet();
adapter.Fill(dset,"Author");
DataGrid1.DataSource = dset.Tables
["Author"].DefaultView;
DataGrid1.DataBind();
}
}
I am not sure if I am missing some keypoints.
Sincerely,
-Reetu
I read about webcontrols and learnt how to display
controls like textbox , buttons etc on the aspx page.
I want to build a webcontrol that would display Datagrid
when placed on the form. I couldn't find a link that would
provide step by step detail on how to do this.
I tried few things and now I can see the data grid control
on the form. When I run the application the page appears
to be blank.
The code is as follows:
public class TasksPage :System.Web.UI.WebControls.DataGrid
{
DataGrid DataGrid1 = new DataGrid();
override protected void OnInit(EventArgs e)
{
// Put user code to initialize the page here
SqlConnection connection = new SqlConnection
("server=(local);database=trial;Trusted_Connection=yes");
string query = "select * from Author";
SqlDataAdapter adapter = new SqlDataAdapter
(query,connection);
DataSet dset = new DataSet();
adapter.Fill(dset,"Author");
DataGrid1.DataSource = dset.Tables
["Author"].DefaultView;
DataGrid1.DataBind();
}
}
I am not sure if I am missing some keypoints.
Sincerely,
-Reetu