473,324 Members | 2,548 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,324 software developers and data experts.

usercontrol initialization question

hallo group!

i have a user control that using a listbox and a dataset to fill it.

usually i can give some parameters in the form of public properties to
user controls for example :

<my:MinMaxAlphaField Required="false" ID="cfCity" Label="City:"
MaxCharacters="50" MinCharacters="3" runat="server"/>

so here im setting the label text and it works fine.

now for the usercontrol that has the listbox i want to pass the dataset.

unfortunately i seem to be able to just pass strings there so my
question is, how can i pass a dataset from outside?

the dataset itself is the result of a methodcall.

the page containing all this is using a wizard control and the data
depends on a wizard step before, so i tried to pass the dataset in the
wizardstep event, but this assignment seems to be done after the control
is rendered, cause if i set a breakpoint in the control's page_load
event where the dataset is assigned to the listbox its still null.

how can i accomplish my mission? i hope its understandable.

cheers

florian
Oct 21 '08 #1
1 1117
Good evening,

1. Programatic data binding:
Add new property called i.e. MyListDataSource and a method:

public object MyListDataSource
{
get
{
return myListBox.DataSource;
}
set
{
myListBox.DataSource = value;
}
}

public void MyListDataBind()
{
myListBox.DataBind();
}

finally, in code behind of the page you placed your control:

cfCity.DataSource = myDataSet;
cfCity.DataBind();

2. Declarative data binding.
If you are planning to use any of the data source control (SqlDataSource,
ObjectDataSource, etc) add one additional property:

public string MyListDataSourceID
{
get
{
return myListBox.DataSourceID;
}
set
{
myListBox.DataSourceID = value;
}
}

<my:MinMaxAlphaField Required="false" ID="cfCity" Label="City:"
MaxCharacters="50" MinCharacters="3" runat="server"
MyListDataSourceID="mySqlDataSource" />

I would implement both options to give user control users a choice.

Hope this helps
--
Milosz
"Florian Paulus" wrote:
hallo group!

i have a user control that using a listbox and a dataset to fill it.

usually i can give some parameters in the form of public properties to
user controls for example :

<my:MinMaxAlphaField Required="false" ID="cfCity" Label="City:"
MaxCharacters="50" MinCharacters="3" runat="server"/>

so here im setting the label text and it works fine.

now for the usercontrol that has the listbox i want to pass the dataset.

unfortunately i seem to be able to just pass strings there so my
question is, how can i pass a dataset from outside?

the dataset itself is the result of a methodcall.

the page containing all this is using a wizard control and the data
depends on a wizard step before, so i tried to pass the dataset in the
wizardstep event, but this assignment seems to be done after the control
is rendered, cause if i set a breakpoint in the control's page_load
event where the dataset is assigned to the listbox its still null.

how can i accomplish my mission? i hope its understandable.

cheers

florian
Oct 21 '08 #2

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

Similar topics

1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
2
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
7
by: Javaman59 | last post by:
This is about finding the right point at which to save user entered data in the registry, so that when the application is restarted, the saved values will be restored. I want this behaviour to be...
1
by: | last post by:
Hi, All, I'm having problems getting OnInit to fire in my UserControl, when I use a custom template to render the control. The control will render to the browser and it wasn't until I needed...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
0
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
1
by: Giovanni | last post by:
Dear Friends/Gurus, I have exhausted myself and have yet no solution to the following: I have an ASP.NET 2.0 Survey type application. On a page, I have placed a GridView which is bound to an...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
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.