Web Control that inherits the DataGrid

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Web Control that inherits the DataGrid

    Hi!

    Does anyone have a sample on how i can inherit the datagrid in a Web Control
    and bind it to a datasource.
    And then add template columns and add data from the datasource into the
    columns

    My Web Control inherits the DataGrid, i bind the control to a datasource
    (DataReader) in my aspx code (Page_Load event)

    But i can't get data from the DataItem in OnItemDataBound event in my Web
    Control.

    protected override void OnItemDataBound(DataGridItemEventArgs e)
    {
    LinkButton lb = new LinkButton();
    lb.ID = "lbNav";

    *** This row causes a "Object reference not set to an instance of an
    object" ***
    lb.Text = ((DataRowView)e.Item.DataItem).Row.ItemArray[1].ToString();

    e.Item.Cells[0].Controls.Add(lb);
    base.OnItemDataBound (e);
    }

    /Jonas



    Jonas Nilsson Guest

  2. Similar Questions and Discussions

    1. Textbox2 control that inherits from Textbox
      Hi Guys, I have a huge problem....I think. I have created a control called Textbox2 which basically inherits from Textbox. Now my problem is...
    2. DataGrid with Inherits
      Hi I didn't have any problem with DataGrid with the Inherits options (ie. an aspx page with the corresponding code in assembly) even with sorting. ...
    3. Is it possible to inherits from SoapException to create custom exception
      Hi all, I try to create a class who inherits from SoapException Public class SoapExceptionTst inherits SoapException public sub new (....)...
    4. Control derived from datagrid, problem with adding other control and databinding (VB)
      I all, my employer required me to add a bunch of control to a datagrid (such as a drop down list on top corner to select page size and prev, bunch...
    5. How to change what the Web Service Proxy class inherits from?
      I am successfully using SoapExtensionImporter to change how the web service proxy class is generated when I add web reference in VS. However, this...
  3. #2

    Default Re: Web Control that inherits the DataGrid

    Morning Jonas,

    Try this link
    [url]http://msdn.microsoft.com/msdnmag/issues/01/10/cutting/cutting0110.asp[/url]
    Build a Variety of Custom Controls Based on the DataGrid Control by Dino
    Esposito

    He rocks!!

    Hope this helps,

    --
    Noel Hoo
    [email][email protected][/email]

    "Jonas Nilsson" <[email protected]> wrote in message
    news:[email protected]..
    > Hi!
    >
    > Does anyone have a sample on how i can inherit the datagrid in a Web
    Control
    > and bind it to a datasource.
    > And then add template columns and add data from the datasource into the
    > columns
    >
    > My Web Control inherits the DataGrid, i bind the control to a datasource
    > (DataReader) in my aspx code (Page_Load event)
    >
    > But i can't get data from the DataItem in OnItemDataBound event in my Web
    > Control.
    >
    > protected override void OnItemDataBound(DataGridItemEventArgs e)
    > {
    > LinkButton lb = new LinkButton();
    > lb.ID = "lbNav";
    >
    > *** This row causes a "Object reference not set to an instance of an
    > object" ***
    > lb.Text = ((DataRowView)e.Item.DataItem).Row.ItemArray[1].ToString();
    >
    > e.Item.Cells[0].Controls.Add(lb);
    > base.OnItemDataBound (e);
    > }
    >
    > /Jonas
    >
    >
    >

    Noel Hoo Guest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139