Thank you, i understand why mine did not work. Youer help was greatly
appreciated.
Thanks
KES
"bruce barker" wrote:
> assuming your control is not nested (which would require recursion):
>
> for (int i = 0; i < gvr.Cells.Count; i++ )
> {
> foreach (Control c in gvr.Cells[i].Controls)
> {
> if (c.ID == ctrlID)
> return i;
> }
> }
>
>
> -- bruce (sqlwork.com)
>
>
> "WebBuilder451" wrote:
>
> > bruce, i appreciate your response,
> >
> > I think that is what i was trying to do, but i don't know how to isolate
> > each cell so that i can get to the collection.
> > i tried var Tablecell td = e.row.cells[i];
> > and for reasons you noted it does not work. I don't think a recursive call
> > will change this(?)
> >
> >
> > --
> > (i''ll be asking a lot of these, but I find C# totally way cooler than vb
> > and there''s no go''n back!!!)
> > thanks (as always)
> >
> > kes
> >
> >
> > "bruce barker" wrote:
> >
> > > all the cell have the same NamingContainer (which is what FindControl uses).
> > > you will have to search each cells Control collection (maybe recursivly) for
> > > a control with the desired ID.
> > >
> > > -- bruce (sqlwork.com)
> > >
> > >
> > > "WebBuilder451" wrote:
> > >
> > > > I'm attempting find the cell id, i (e.row.cells[i] ) given a control in that
> > > > cell.
> > > > using this function:
> > > > private int GetcellPosition(GridViewRow gvr, string ctrlID)
> > > > {
> > > > var iCell = -1;
> > > > for (int i = 0; i < gvr.Cells.Count; i++ )
> > > > {
> > > > if ( gvr.Cells[i].FindControl(ctrlID) != null )
> > > > {
> > > > iCell = i;
> > > > break;
> > > > }
> > > > }
> > > > return iCell;
> > > > }
> > > > CALL: e.Row.Cells[GetcellPosition(e.Row, "LabelPerBS")].CssClass= "gvir2";
> > > >
> > > > this does not work. It appears to be doing a find on the entire row so the
> > > > first position always gets returned. Is there a way to do this or am i
> > > > hitting a limitation?
> > > >
> > > > thanks
> > > >
> > > > kes
|