C#/ASP.NET code behind access the objects in Web Control on the fo

  • Thread starter Thread starter JB
  • Start date Start date
J

JB

Helllo

When using C# and ASP.NET the code behind pages intellesense easily
accesses the objects used on the form for (example datagridview1.datasource =
mydb) , but if the datagridview is placed in a Web Control on the form how
can intellisense access the datagridview1.datasource property when the
datagridview object resides in a Web Control that is on the form?
 
Because container controls are completely compiled until runtime, the VS
editor can't always give you intellisense on them, even when you fully
qualify what it is you want.
 
Hello Scott

Since intellisense cant access the objects residing in a Web Control,
how can I syntactly (preferably) or any other way do something like
populating DropDownLists, DataGridViews and TextBoxes that reside in a Web
Control on a form using the codebehind, if it is possble?

JB
 
You'll have to loop through the yourwebcontrol.Controls list of the web
control that has your grids, dropdowns (effectively any child control it
contains) and check the control type of each. If you are looking for a
Dropdowncontrol and the controltype of currnet object is dropdown list
(you'll get this through intellisense), you'll assign the object to a
dropdown control instance (e.g DropdownList myDropdown = <curent child
control>). From then on, you can use the dropdown object as you normally do.
 
Back
Top