473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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

Nov 23 '05 #1
5 1691
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

<Du************@gmail.com> wrote in message
news:11********************@g14g2000cwa.googlegrou ps.com...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

Nov 23 '05 #2
Du************@gmail.com wrote:
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
}

Nov 23 '05 #3
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(Pa ge,"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!

Nov 23 '05 #4
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(Pa ge,"V_cl_id");
foreach (System.Web.UI.Control wc in webControls)
{
IronSpeed.Base.Web.UI.WebControls.FieldValueDropDo wn dlsebas =
(IronSpeed.Base.Web.UI.WebControls.FieldValueDropD own)wc;
Response.Write(dlsebas.SelectedValue.ToString());
}

Nov 23 '05 #5
Hi,

Good to know you solved it.

Happy thanksgiving for you too
cheers,

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

"Basdub" <Du************@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
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(Pa ge,"V_cl_id");
foreach (System.Web.UI.Control wc in webControls)
{
IronSpeed.Base.Web.UI.WebControls.FieldValueDropDo wn dlsebas =
(IronSpeed.Base.Web.UI.WebControls.FieldValueDropD own)wc;
Response.Write(dlsebas.SelectedValue.ToString());
}

Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
10
by: Martin Vorbrodt | last post by:
Example code in one of my books intrigues me: class B { public: B* Clone() const { B* p = DoClone(); assert(typeid(*p) == typeid(*this)); return p; }
16
by: junky_fellow | last post by:
I was reading the various posts in this newsgroup, and found that main function should be declared as int main(void) // if no arguments are passed to main i wanted to know whats the purpose of...
2
by: Sam | last post by:
In our C++ program, we are using the system call to execute another C++ program synchronously. The program executed by system runs without error and returns back a 0. Under conditions we cannot...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
3
by: msnews.microsoft.com | last post by:
Hi i am using User32.dll in Visual stdio 2005. public static extern long SetActiveWindow(long hwnd); public static extern long keybd_event(byte bVk, byte bScan, long dwFlags,
4
by: Ralf Rennartz | last post by:
Hello NG, i have the following function which works fine: Public Shared Function getFullDatagrid() As System.Web.UI.WebControls.DataGrid Dim myGrid As New...
7
by: Computer Guru | last post by:
Hi, Pardon the unclear/verbose subject, I just can't think of another way of phrasing it. Basically, I can assign the (for instance) "Location" property of a picture box to a data-bound item....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.