473,322 Members | 1,347 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.

Help me with IsPostBack

I have a a WebForms.Table control that I am populating in Page_Load(). One
of the columns has cells with a button in each row, which I wire up to its
Click event handler. Everything is fine if I don't condition the table fill
on IsPostBack. But if I use IsPostBack, like so:

Page_Load()
{
if (!IsPostBack)
{
fill the table, including creating the buttons
}

// Then wire up the buttons
foreach (row in the table)
{
attach the click event handler
}
}

then the table is empty.

The table fill is costly and I'd only like to fill it once. Can you help me
with this. I do have EnableViewState=true on the table control.

-- Alan
Nov 18 '05 #1
3 1437
you have to refill the table on postback if you want to get events, or look
at postback values.

-- bruce (sqlwork.com)
"Alan Pretre" <no@spam> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
I have a a WebForms.Table control that I am populating in Page_Load(). One of the columns has cells with a button in each row, which I wire up to its
Click event handler. Everything is fine if I don't condition the table fill on IsPostBack. But if I use IsPostBack, like so:

Page_Load()
{
if (!IsPostBack)
{
fill the table, including creating the buttons
}

// Then wire up the buttons
foreach (row in the table)
{
attach the click event handler
}
}

then the table is empty.

The table fill is costly and I'd only like to fill it once. Can you help me with this. I do have EnableViewState=true on the table control.

-- Alan

Nov 18 '05 #2
You can write a function named ShowTable(). and then you
should invole it in page_load without if(!IsPostBack).
private void ShowTable(){
// here build a table and its event
}

public void Page_Load(){
this.ShowTable();
if(!IsPostBack){
// your other logic code
}
}

and you can invole showtable function in InitCommponent()
function of current page.I think so!
-----Original Message-----
I have a a WebForms.Table control that I am populating in Page_Load(). Oneof the columns has cells with a button in each row, which I wire up to itsClick event handler. Everything is fine if I don't condition the table fillon IsPostBack. But if I use IsPostBack, like so:

Page_Load()
{
if (!IsPostBack)
{
fill the table, including creating the buttons
}

// Then wire up the buttons
foreach (row in the table)
{
attach the click event handler
}
}

then the table is empty.

The table fill is costly and I'd only like to fill it once. Can you help mewith this. I do have EnableViewState=true on the table control.
-- Alan
.

Nov 18 '05 #3
If your table fill is costly, is the data quite consistent, i.e. does it
change much? If not, you might want to consider creating a user control to
house the table. Then have an OutputCache setting on that user control see
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcachingportionsofaspnetpage.asp
http://support.microsoft.com/default.aspx?kbid=308375

Alternatively, if it is the aquisition of the data for the table which is
costly, store the data somehow rather than hitting a database each time.
For e.g. in ViewState or Session state?

Regards

Andy Mortimer [MS]
Please do not send email directly to this alias. This alias is for
newsgroup purposes only
Nov 18 '05 #4

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

Similar topics

3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
5
by: Pierre | last post by:
Hi, I create an dynamic command button like that: buttonCmd= New Button buttonCmd.ID = "IDBTN1" buttonCmd.Text = "Test" AddHandler buttonCmd.Click, AddressOf MessageClick I have this click...
1
by: Jonathan Yong | last post by:
I observe a very weird behavior when dynamically create web control and bind events to it. Create a C# ASP.NET application, Put a PlaceHolder and Textbox onto the Web form, and try with the 4...
2
by: Pravin | last post by:
Hi, I have a doubt that how does ASP.NET find out whether the page is accessed for the first time or the page is due to a post back event, and then set the IsPostBack property ? Any ideas. ...
4
by: TJ | last post by:
Hi, There is one aspx web page that contains usercontrol. In aspx page and usercontrol , there is each submit button... Here is what I want... I want to process something depending on each...
7
by: Paul Fi | last post by:
I have this page Index.aspx, page code shown below: void Page_Load(object sender, EventArgs e) { if (IsPostBack) { if (this.drpTypeOfStock.SelectedIndex != 0)...
2
by: tacmec | last post by:
ASP.NET 2.0 (C#) application. I have a web form with a GridView, which is populated dynamically. See the code below. First time to the page, IsPostBack is false. Therefore, DisplayItems() is...
2
by: momo | last post by:
Hello Guys, I have a bit of a problem, I created a Dll called SecureQueryStringDll.dll and I had the dll put bin folder of my application first and it did not work so I then put it in the bin...
0
by: DC | last post by:
Hi, I am dynamically adding a usercontrol that uses "this.IsPostBack" in Page_Load to decide whether it must populate some of it's inner controls or not. Since I am adding the usercontrol to the...
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...
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: 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.