Chris:
I know that your question has already been answered so you'll probably
never look here again, but you might try looking at the DataKeys
collection of the DataGrid to solve your problem in the future, rather
than relying on hidden columns.
Basically, when you are databinding, i.e.:
dataGrid1.DataSource = intentory.GetList();
dataGrid1.DataBind();
Add this before you DataBind() call:
dataGrid1.DataKeyField = "PartID"; // Assuming PartID is serializable
Later, in your ItemCommand event handler, you can just do this:
string partID = dataGrid1.DataKeys[e.Item.ItemIndex].ToString();
To retrieve the PartID. Makes things cleaner if you ask me... but you
didn't! :)
Enjoy,
Sean
[quoted text, click to view] Chris H. wrote:
> Fellow .Netters,
>
> I have come to an impass trying to "hide" a column on a data grid - I'm sure
> it's a fairly simple thing (but so am I, that's why I'm stuck)
>
> Imagine if you will that I have a table as structure thus (this is all an
> example)
>
> PartID (string)
> Part Code (string)
> Description (string)
> InStock (string)
>
> Now, the PartID field is purely an internal code which has no display value
> whatsoever but is needed internally by the system for various other purpose.
>
> My Select statement is simply "Select * from Parts...." and what I want to
> do is display all the columns, except the Part ID...but retain the PartID
> for other actions required later (as it's in a specific format)
>
> Please put me out of my misery and help me solve this...
>
> Chris....
>
>
Thanks Sean.....any advice is good at the moment, I'm still a novice at
this...just have to work out now how to make the grid Non-Edittable with Row
Selection (just a scrolling list that the user selects and then off it goes
and does some stuff....)
[quoted text, click to view] "Sean Bright" <sean@noreply.com> wrote in message
news:gPmdnb9254ipin_dRVn2gg@giganews.com...
> Chris:
>
> I know that your question has already been answered so you'll probably
> never look here again, but you might try looking at the DataKeys
> collection of the DataGrid to solve your problem in the future, rather
> than relying on hidden columns.
>
> Basically, when you are databinding, i.e.:
>
> dataGrid1.DataSource = intentory.GetList();
> dataGrid1.DataBind();
>
> Add this before you DataBind() call:
>
> dataGrid1.DataKeyField = "PartID"; // Assuming PartID is serializable
>
> Later, in your ItemCommand event handler, you can just do this:
>
> string partID = dataGrid1.DataKeys[e.Item.ItemIndex].ToString();
>
> To retrieve the PartID. Makes things cleaner if you ask me... but you
> didn't! :)
>
> Enjoy,
> Sean
>
> Chris H. wrote:
>
> > Fellow .Netters,
> >
> > I have come to an impass trying to "hide" a column on a data grid - I'm
sure
> > it's a fairly simple thing (but so am I, that's why I'm stuck)
> >
> > Imagine if you will that I have a table as structure thus (this is all
an
> > example)
> >
> > PartID (string)
> > Part Code (string)
> > Description (string)
> > InStock (string)
> >
> > Now, the PartID field is purely an internal code which has no display
value
> > whatsoever but is needed internally by the system for various other
purpose.
> >
> > My Select statement is simply "Select * from Parts...." and what I want
to
> > do is display all the columns, except the Part ID...but retain the
PartID
> > for other actions required later (as it's in a specific format)
> >
> > Please put me out of my misery and help me solve this...
> >
> > Chris....
> >
> >
> >