Function that return System.Web.UI.Control[]

  • Thread starter Thread starter Dube.Sebastien
  • Start date Start date
D

Dube.Sebastien

I have a function that return System.Web.UI.Control[].
It's a custom vb function that i call in C# that is defined as

Public Function FindControlsByID(ByVal container As
System.Web.UI.Control, ByVal id As String) As System.Web.UI.Control()

I have a hard time figuring out in what type of variable i can put the
result in.

I always end up with a compilation error:

Cannot convert type System.Web.UI.Control[] to "whatever i try".

Thankd for your help
 
Hi,

What is the use of the method?

If it does return a System.Web.UI.Control[] then you should treat as that.

What you want to do with it?
Cannot convert type System.Web.UI.Control[] to "whatever i try".

Did yout ried this:
object o = FindControlsByID( .. )


cheers,



--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



I have a function that return System.Web.UI.Control[].
It's a custom vb function that i call in C# that is defined as

Public Function FindControlsByID(ByVal container As
System.Web.UI.Control, ByVal id As String) As System.Web.UI.Control()

I have a hard time figuring out in what type of variable i can put the
result in.

I always end up with a compilation error:

Cannot convert type System.Web.UI.Control[] to "whatever i try".

Thankd for your help
 
I have a function that return System.Web.UI.Control[].

It returns an array of System.Web.UI.Control
I have a hard time figuring out in what type of variable i can put the
result in.

I think it should be something like this:

System.Web.UI.Control[] webControls = FindControlsById(...);
foreach (System.Web.UI.Control wc in webControls)
{
//Work with wc here
}
 
Man thanks you were the light at the end of my tunnel!

I have a hard time working with container. I'm devolping using
Ironspeed Designer. A user created a function mentionned above to
retrieve a control hidden into a container or a recordrow repeater.

Anyway there was no info on how to use it. So the Function return an
array of all the controls in a given container with the specified ID.

Then i wanted to transfer to a Ironspeed.......DropdownList to use it
as "usual". so what i did, with your help, is:

object dl =
IronSpeed.Base.Utils.MiscUtils.FindControlsByID(Page,"V_cl_id");
IronSpeed.Base.Web.UI.WebControls.DropDownList dlsebas =
IronSpeed.Base.Web.UI.WebControls.DropDownList)dl;

I think this will allow me to interact with the control as before. Hope
it will though. I'm testing it right away!
 
You both saved my Thanksgiving week. Therefore, Thanksgiving your time
to help!

The fully usable code is (i don't think it would interest you) but
anyway here it is:

System.Web.UI.Control[] webControls =
IronSpeed.Base.Utils.MiscUtils.FindControlsByID(Page,"V_cl_id");
foreach (System.Web.UI.Control wc in webControls)
{
IronSpeed.Base.Web.UI.WebControls.FieldValueDropDown dlsebas =
(IronSpeed.Base.Web.UI.WebControls.FieldValueDropDown)wc;
Response.Write(dlsebas.SelectedValue.ToString());
}
 
Hi,

Good to know you solved it.

Happy thanksgiving for you too


cheers,
 
Back
Top