Dynamically binding a Datagrid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Deepa

    #1

    Dynamically binding a Datagrid

    I am doing an ASP.Net application wherein I have a datagrid which I need to
    populate dynamically. The grid has 5 rows and two columns. In the 2nd col I
    need to insert dropdown boxes. I'll have to populate both the cols from the
    database. The values for the 2 cols come from 2 diff tables. How do I do this?

    Also in the design mode, do I have to manually mention the Collections
    property of the datagrid columns as Template Columns?

    This is urgent. I'd appreciate if someone can help me.

    Thanks
  • JV

    #2
    Re: Dynamically binding a Datagrid

    Probably the easiest way is to use a Connection object, a Data Adapter (one
    for each table, in your case) and a DataSet. If you create a connection in
    the server explorer (look on the left) you can drag a table from in there
    onto your form and it will create the first two for you. Beyond that,
    please reference the online help for binding a DataGrid to DataSet and it
    should become pretty clear.

    As far as the dropdown boxes, you are correct, you will want to make that a
    template column.

    In addition to http://msdn.microsoft.com I find that there's a lot of
    helpful examples on some other web sites like http://www.codeproject.com
    (free to sign up).


    "Deepa" <Deepa@discussi ons.microsoft.c om> wrote in message
    news:828D4F3B-A075-496D-A213-33DE0134C542@mi crosoft.com...[color=blue]
    >I am doing an ASP.Net application wherein I have a datagrid which I need to
    > populate dynamically. The grid has 5 rows and two columns. In the 2nd col
    > I
    > need to insert dropdown boxes. I'll have to populate both the cols from
    > the
    > database. The values for the 2 cols come from 2 diff tables. How do I do
    > this?
    >
    > Also in the design mode, do I have to manually mention the Collections
    > property of the datagrid columns as Template Columns?
    >
    > This is urgent. I'd appreciate if someone can help me.
    >
    > Thanks[/color]


    Comment

    Working...