To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
"Reetu" <reetu@ascentn.com> wrote in message
news:018301c34a2d$c36b51c0$a301280a@phx.gbl...
> Hello Victor,
>
> I just made a silly mistake. Now I can see datagrid along
> with data when executed. It works fine now.
>
> Thanks & Regards,
> -Reetu
>
> >-----Original Message-----
> >Hi Victor,
> >
> >PROBLEM:
> >
> >I am trying to achieve the following functionality.
> >
> >Presently I have a grid control placed on an aspx page
> >from the toolbox which has five columns and it displays
> >data from the database.
> >We are using some of our own APIs in the code. In many of
> >the functions on that page we have to keep repeating few
> >lines of code(containing our APIs) again and again.
> >
> >SOLUTION:
> >So we plan to build a web custom control so that :
> >
> >1. When we drag and drop the web control from the
> toolbox,
> >we should see the datagrid, the data from the database
> >when executed.
> >2. The lines of code which we keep repeating can be plaed
> >in webcontrol.
> >
> >I am a bit lost on how to proceed ahead after inheriting
> >the class.
> >public class TasksPage :System.Web.UI.WebControls.DataGrid
> >
> >I would really appreciate if I am provided with some link
> >or article that would provide some details.
> >
> >Thanks & Regards,
> >-Reetu
> >
> >
> >>-----Original Message-----
> >>Hi reetu,
> >>
> >>You may be confusing things a little. If you just want
> to
> >extend DataGrid
> >>functionallity then inheriting from the DataGrid class
> >may be a good choice
> >>but in your sample code you're also creating another
> >instance of a DataGrid,
> >>I'm not sure why you're doing this, could you add a
> >little on what exactly
> >>are you trying to achieve?. Also for handling the design-
> >time representation
> >>of your custom controls, specially ones with complex
> >output, considering
> >>writing a custom designer (take a look a ControlDesigner
> >class) to have more
> >>control over what gets rendered at design-time,
> >>
> >>--
> >>Victor Garcia Aprea
> >>Microsoft MVP | ASP.NET
> >>Looking for insights on ASP.NET? Read my blog:
> >>
http://obies.com/vga/blog.aspx > >>To contact me remove 'NOSPAM'. Please post all questions
> >to the newsgroup
> >>and not by private mail.
> >>
> >>"reetu" <reetu@ascentn.com> wrote in message
> >>news:046601c34808$b648abe0$a401280a@phx.gbl...
> >>> 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
> >>>
> >>>
> >>
> >>
> >>.
> >>
> >.
> >