Re: DataGrid Colum Names

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Fred Nelson (fred_at_smartybird.com)
Date: 04/13/04


Date: Mon, 12 Apr 2004 21:45:09 -0400

Bill:

Thanks for your quick answer - I really appreciate it!

I am a newby and so I'm confused about the reply that you gave. I have
loaded my datagrid with the following:

dim myproclib as new datafunctions.datalib

dim datagrid1 as new datagrid
datagrid1.datasource = myproclib.getstates
datagrid1.databind()

So I haven't (or I think I haven't) created a data table and then bound the
grid to it. Should I create a datatable from the stored procedure? If I
create one then can I populate it without knowing the column names I will
receive?

Again, thanks for your help!

Fred

"William Ryan eMVP" <bill@NoSp4m.devbuzz.com> wrote in message
news:OrzIeOPIEHA.3476@TK2MSFTNGP11.phx.gbl...
> Fred:
>
> You'll reference the DataTable that you bound the grid to. Whatever it's
> name is, reference it. How it got filled (ie Stored Proc) doesn't matter.
> Depending on how you called DataAdapter.Fill, you may want to use the
> Numeric Index of hte Tables collection ie
> myDataSet.Tables[0].Columns[0].ColumnName;
>
> conceptually, focus on hitting the datasource with wahtever you want. The
> grid is just the presentation of the underlying data obejct. On the Web,
> changes won't necessarily be reflected visibly until a postback occurs,
but
> on the desktop, as soon as you change the underlying table value
> programmatically, the change will be visible in the Grid immediately.
>
> HTH,
>
> Bill
> "Fred Nelson" <fred@smartybird.com> wrote in message
> news:eT1HpgOIEHA.2252@TK2MSFTNGP10.phx.gbl...
> > Bill:
> >
> > Thanks for your reply - it looks like I may get this to work!
> >
> > I don't understand one thing - in the example that I provided I bound
the
> > data grid to a class library with a stored procedure that loaded it.
I'm
> > unclear how to reference the underlying data table in this example where
> > datagrid1 contains the data.
> >
> > DataGrid1.Colums[0].ColumnName is not valid syntax -
> >
> > Do I need to create a data table from the stored procedure rather than a
> > data grid - or is there something I'm missing?
> >
> > Thanks again for your help!
> >
> > Fred
> >
> >
> > "William Ryan eMVP" <bill@NoSp4m.devbuzz.com> wrote in message
> > news:uLtgMEOIEHA.4032@TK2MSFTNGP12.phx.gbl...
> > > If it's bound to a grid, then the grid column should correspond with
the
> > > columns in the underlying datatable. As such, you can interrogate the
> > > DataTable's column's collection and just lookup the ColumnName
property
> ie
> > > DataTable.Columns[0].ColumnName;
> > >
> > > HTH,
> > >
> > > bill
> > > "Fred Nelson" <fred@smartybird.com> wrote in message
> > > news:OWHy3WNIEHA.3040@TK2MSFTNGP09.phx.gbl...
> > > > I have an application in which it would be VERY beneficial if I
could
> > > obtain
> > > > the names of the colums in a datagrid.
> > > >
> > > > For example
> > > >
> > > > dim datagrid1 as new datagrid
> > > > datagrid1.datasource = (stored procedure that loads datagrid)
> > > > datagrid1.databind()
> > > >
> > > > I am able to obtain the data in the datagrid by its relative number
> > > however
> > > > I can't figure out how to get the names and in this application they
> may
> > > > change over time.
> > > >
> > > > Any help would be GREATLY appreciated!
> > > >
> > > > Thanks,
> > > >
> > > > Fred
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: DataGrid Colum Names
    ... You'll reference the DataTable that you bound the grid to. ... grid is just the presentation of the underlying data obejct. ... Bill ...
    (microsoft.public.dotnet.languages.vb)
  • Re: CLR event model
    ... You might want to check out Ian Griffiths' Weak Reference events handlers ... object that implements the eventhandler. ... I wanted the grid to be notified of any ... all business objects now held a reference to the collection ...
    (microsoft.public.dotnet.framework.clr)
  • Re: CLR event model
    ... and not a reference to the Program object. ... > object that implements the eventhandler. ... I wanted the grid to be notified of any ... all business objects now held a reference to the collection ...
    (microsoft.public.dotnet.framework.clr)
  • Re: DataGrid updates in Windows Forms - Am I going crazy?
    ... The thing you have to realize is that what you are showing in the grid ... is completely disconnected from the underlying data source. ... I am populating the DataGrid with NP, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Garmin Geko - Accuracy of conversion to Bristish National Grid
    ... Looking at the above reference it would appear that I also need to be ... > able to set the latitude of the origin to 49 Deg North. ... > resulting grid reference is useless. ... user AFTER you have set the display format. ...
    (sci.geo.satellite-nav)