Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Microsoft #1
How to avoid accessing row values with hard coded index
Hi there ,
My code look like this,
string var1,var2,var3,var4;
foreach (DataGridItem item in MyDataGrid.Items)
{
var1 = item.Cells[0].Text;
var2 = item.Cells[1].Text;
var3 = item.Cells[2].Text;
var4 = item.Cells[3].Text;
}
How can access the row data with column header text instead of hard coded
index's. Like
var1 = item.Cells["ID"].Text;
var2 = item.Cells["FromDate"].Text;
var3 = item.Cells["ToDate"].Text;
var4 = item.Cells["TransferDate"].Text;
Thanks
Baski
Microsoft Guest
-
hard-coded path?
I'm a complete newb to swf. I haven't got a clue yet what's going on. I've built a simple little swf that implements a visualization algorithm... -
Displaying multiple values - Hard to explain here...
Hi All! Ok. I've got a query that's pulling data from multiple child tables based on the primary key from the parent table and displaying it in... -
duplicate values in the index, primary key, or relationship
I have a MSA2K db. Table: customers Columns: fileNumber: (primary) Indexed(No Duplicates) fileName Client ClientType fileYear boxNumber:... -
must all global list be hard-coded in?
As customary, I use parameter dialogue boxes for most of the settings that I would change frequently; however, it seems that you can not use a... -
DISABLE The hard coded IE5+ security risk file types
I understand according to this article: http://support.microsoft.com/?id=232077 That there are hardcoded file types in IE that demands the... -
Alvin Bruney #2
Re: How to avoid accessing row values with hard coded index
this is an oversight on the part of MS. You can only access via an index. If
you really need this you will need to do a typed dataset
"Microsoft" <baski@aldensys.com> wrote in message
news:enWWnMqgDHA.2916@tk2msftngp13.phx.gbl...> Hi there ,
>
> My code look like this,
>
> string var1,var2,var3,var4;
>
> foreach (DataGridItem item in MyDataGrid.Items)
>
> {
>
> var1 = item.Cells[0].Text;
>
> var2 = item.Cells[1].Text;
>
> var3 = item.Cells[2].Text;
>
> var4 = item.Cells[3].Text;
>
> }
>
> How can access the row data with column header text instead of hard coded
> index's. Like
>
>
>
> var1 = item.Cells["ID"].Text;
>
> var2 = item.Cells["FromDate"].Text;
>
> var3 = item.Cells["ToDate"].Text;
>
> var4 = item.Cells["TransferDate"].Text;
>
>
>
> Thanks
>
> Baski
>
>
Alvin Bruney Guest
-
Perecli Manole #3
Re: How to avoid accessing row values with hard coded index
What I did is created an enumeration with one member for each column with a
value assigned to that of the coresponding index.
Private Enum EnumName
Column1 = 0
Column2 = 1
...
...
End Enum
Then whenever you need to access the cell do like so:
item.Cells[EnumName.Column1 ].Text
The benefit with this is that when you add or remove a column all you have
to do is adjust the enumeration. You won't have to go through every line of
code and change the indexes.
Perry
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:O%23EOdEThDHA.2212@TK2MSFTNGP09.phx.gbl...If> this is an oversight on the part of MS. You can only access via an index.coded> you really need this you will need to do a typed dataset
> "Microsoft" <baski@aldensys.com> wrote in message
> news:enWWnMqgDHA.2916@tk2msftngp13.phx.gbl...> > Hi there ,
> >
> > My code look like this,
> >
> > string var1,var2,var3,var4;
> >
> > foreach (DataGridItem item in MyDataGrid.Items)
> >
> > {
> >
> > var1 = RegisterHiddenField> >
> > var2 = item.Cells[1].Text;
> >
> > var3 = item.Cells[2].Text;
> >
> > var4 = item.Cells[3].Text;
> >
> > }
> >
> > How can access the row data with column header text instead of hard>> > index's. Like
> >
> >
> >
> > var1 = item.Cells["ID"].Text;
> >
> > var2 = item.Cells["FromDate"].Text;
> >
> > var3 = item.Cells["ToDate"].Text;
> >
> > var4 = item.Cells["TransferDate"].Text;
> >
> >
> >
> > Thanks
> >
> > Baski
> >
> >
>
Perecli Manole Guest



Reply With Quote

