473,320 Members | 1,950 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,320 software developers and data experts.

BindData() - may I call it manually within Page_Load()?

Hi!

When is BindData() usually called?
Is it OK to call it within Page_Load() so that I have the content of the
bound controls?

Thanks

Rudi
Feb 27 '07 #1
3 1141
Rudi,

Probably you mean the DataBind() method. Yes, it is perfectly ok to do what
you want.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Rudi Hausmann" <ru*****@nospam.comwrote in message
news:74**************************@news.inode.at...
Hi!

When is BindData() usually called?
Is it OK to call it within Page_Load() so that I have the content of the
bound controls?

Thanks

Rudi

Feb 27 '07 #2
"Rudi Hausmann" <ru*****@nospam.comwrote in message
news:74**************************@news.inode.at...
When is BindData() usually called?
I assume that BindData() is a custom method you have written to fetch a
collection of data from your database which is then bound to various web
controls...?

If so, you call it whenever it's needed... :-)
Is it OK to call it within Page_Load() so that I have the content of the
bound controls?
Absolutely! However, you will almost certainly want to enclose it in a if
(!isPostBack) loop so that it doesn't get run twice, especially if e.g. you
have a method which updates data in response to a button click...

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}

protected void cmdSave_Click(object sender, System.EventArgs e)
{
// save the data...
BindData();
}

private void BindData()
{
// fetch the data from the database
}
Feb 27 '07 #3
Rudi Hausmann wrote:
Hi!

When is BindData() usually called?
Is it OK to call it within Page_Load() so that I have the content of the
bound controls?

Thanks

Rudi
Oops, I ment DataBind() of course. Sorry for the confusion...
Feb 27 '07 #4

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

Similar topics

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...
0
by: Itai | last post by:
Background: I have four Web Form pages with respective C# code behind files, all in the same project: localhost/vpath1 Page1.aspx Page2.aspx
4
by: Rob Shorney | last post by:
Hi, I am using .Net 2003 , c# asp.net. The situation i have is this. I have a asp.net page which in the codebehind maintains an xml document in memory. The user can click on a button to popup a...
6
by: Olivier Matrot | last post by:
Hello, This has probably been asked several times, but It must be clarified for me. I would like to know why sometimes during a postback Page_Load is called after the function marked for...
3
by: anadimpa | last post by:
Hello all I build a javascript function string in the code behind and register it in the Page_Load of my User Control. I do this because I build the javascript based on some variables that are...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
5
by: Stephen Barrett | last post by:
I have read many threads related to async fire and forget type calls, but none have addressed my particular problem. I have a webpage that instantiates a BL object and makes a method call. The...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
3
by: Ignacio Machin | last post by:
How can I call an event from another event: I want to call : DropDownList_SelectedIndexChanged in: Page_Load
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
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...
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: 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)...
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.