473,770 Members | 6,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a databind method on a webform in a ascx file

Hey everyone. I was wondering if someone could help me with a small problem.
I have designed a user control and I would have inserted it on a aspz page
(WebForm1). The User control is being used to help with the navigation
through a datagrid. The control handles all the paging issues and on the
webform I do all the DataBinding.

My problem is that at the end of code of an on-click event for a link button
on my user control (DataGridNaviga tion.ascx) I need to call the DataBind
Method. The problem is that the DataBind method is sitting on the WebForm1
code behind page.

Here is a part of my code on the Code behind in the user control (ascx.cs
file) and commented is here I need to call the DataBind method.

private void No1_Click(objec t sender, System.EventArg s e)
{
_currentPageNum ber = int.Parse(No1.T ext);
this.CurrentPag e.Text = _currentPageNum ber.ToString();
ShowHideNavigat ion();
/*Need to call the DataBind method in here somehow
This DataBind Method is sitting on the WebForm1 code behind page*/
}

I would be very grateful if someone could help me please.
Jul 21 '05 #1
2 2269
JXT
Stephen:

I have not done a lot of C#, but I know that you can setup a public
property in your user control. That public property would hold a reference
to the datagrid on the main webform. Inside of WebForm1 assign a reference
to the datagrid to the public property of your user control. You will have
to declare your user control as a protected withevents variable in the
WebForm1.aspx. The name of the user control variable will have to match the
ID assigned to the user control in the WebForm.aspx page.

"Stephen" wrote:
Hey everyone. I was wondering if someone could help me with a small problem.
I have designed a user control and I would have inserted it on a aspz page
(WebForm1). The User control is being used to help with the navigation
through a datagrid. The control handles all the paging issues and on the
webform I do all the DataBinding.

My problem is that at the end of code of an on-click event for a link button
on my user control (DataGridNaviga tion.ascx) I need to call the DataBind
Method. The problem is that the DataBind method is sitting on the WebForm1
code behind page.

Here is a part of my code on the Code behind in the user control (ascx.cs
file) and commented is here I need to call the DataBind method.

private void No1_Click(objec t sender, System.EventArg s e)
{
_currentPageNum ber = int.Parse(No1.T ext);
this.CurrentPag e.Text = _currentPageNum ber.ToString();
ShowHideNavigat ion();
/*Need to call the DataBind method in here somehow
This DataBind Method is sitting on the WebForm1 code behind page*/
}

I would be very grateful if someone could help me please.

Jul 21 '05 #2
JXT
Stephen:

I have not done a lot of C#, but I know that you can setup a public
property in your user control. That public property would hold a reference
to the datagrid on the main webform. Inside of WebForm1 assign a reference
to the datagrid to the public property of your user control. You will have
to declare your user control as a protected withevents variable in the
WebForm1.aspx. The name of the user control variable will have to match the
ID assigned to the user control in the WebForm.aspx page.

"Stephen" wrote:
Hey everyone. I was wondering if someone could help me with a small problem.
I have designed a user control and I would have inserted it on a aspz page
(WebForm1). The User control is being used to help with the navigation
through a datagrid. The control handles all the paging issues and on the
webform I do all the DataBinding.

My problem is that at the end of code of an on-click event for a link button
on my user control (DataGridNaviga tion.ascx) I need to call the DataBind
Method. The problem is that the DataBind method is sitting on the WebForm1
code behind page.

Here is a part of my code on the Code behind in the user control (ascx.cs
file) and commented is here I need to call the DataBind method.

private void No1_Click(objec t sender, System.EventArg s e)
{
_currentPageNum ber = int.Parse(No1.T ext);
this.CurrentPag e.Text = _currentPageNum ber.ToString();
ShowHideNavigat ion();
/*Need to call the DataBind method in here somehow
This DataBind Method is sitting on the WebForm1 code behind page*/
}

I would be very grateful if someone could help me please.

Nov 22 '05 #3

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

Similar topics

4
2321
by: Stephen | last post by:
Hey everyone. I was wondering if someone could help me with a small problem. I have designed a user control and I would have inserted it on a aspz page (WebForm1). The User control is being used to help with the navigation through a datagrid. The control handles all the paging issues and on the webform I do all the DataBinding. My problem is that at the end of code of an on-click event for a link button on my user control...
2
13732
by: adiel | last post by:
Hello, I am trying to access the properties and methods from a user control within the code-behind file for a webform but I am receiving the message: Name 'MenuBar1' is not declared It does not recognize the user control in the code behind... Here is the code for the user control: MenuBar.ascx:
2
2414
by: a | last post by:
Hi Extremely easy question for someone who knows the answer I'm sure :-) (aren't they all) What exactly does LoadControl do? Whats the difference between calling this and just constructing a user control? Thanks anon'ish
3
12018
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the DataTable, then I discovered the asp:Table has a DataBind method. But the method takes no args and so I'm confused how to use it. Is there a link to see how DataBind works for asp:Table? Should I just use my own code anyway? Thanks... Here's my...
0
1157
by: Bryce Budd | last post by:
Hi, I have a webform which has several server controls attached. The entire form is data bound to custom objects. The collection objects are cached using the Cache object. In my use case, I have to update my database, synchronize my cached collection and refresh my UI. After my database update I call dropdownlist1.databind() and my items are exactly the same when they should be less 1 item. If I understand the "control execution...
1
1485
by: Tomislav Bartolin | last post by:
Hi, I have an aspx page which contains an ascx user control. I am using Page.DataBind in Page_Load event of the page to bind elements to page properties. The problem is the ascx uses its Page_Load event to create objects which are then used for data binding, but because I call Page.DataBind in the parent page, the ascx Page_Load event doesn't complete and its objects are null references, so I get errors.
2
1774
by: Jim Bancroft | last post by:
Hi everyone, I have a DropDownList I populate as outlined below. This is from my code-behind file: private void Page_Load(object sender, System.EventArgs e) { BindMyData(); DataBind(); }
0
1581
by: mike | last post by:
How do i perform a databind on a web user control within a repeater or rather how can I access the datasource that is already bound? I have a web user control that displays a table of values (the profile of a piece of equipment) from SQLServer. I've used a repeater on the webform since a query (i.e. by address) against the DB may return multiple machine profiles and I want to use the repeater to display as many machine profiles as are...
2
2115
by: cmay | last post by:
A common situation I come across is an ASCX control that being used as a lookup control. The ascx might be called "StatusLookup" or something, and it consists of 1 dropdown list that populates itself from cache/database list. If you databind on the Init event, then you are databinding every time, and not making any use of the viewstate. If you databind on the Load event, you can see if the control has
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.