Very, very, easy question

J

John Hoge

I need to do something on a page with a datagrid in the case where the
page is loaded but the Update button is *not* clicked.

Specifically, I am adding a blank row to the dataset with an external
Add button. The dataset is strongly typed, so I can't add a blank
value to the primary key. I put a "Temp" string in this field so the
user can add a new value when the page is loaded with that row set as
editable. If the user doesn'
t click update, I want to reload the dataset from the dataadapter and
bind to the datagrid, thus removing the temporary row that has not
been filled out.

Is there a way, short of a kludge like using session variables in
every other event, that I can test for this using the EventArgs object
passed to Page_Load?

Thanks
 
J

John Hoge

Curt_C said:
if(!IsPostBack())
{
no click here
}
else
{
somethign posted back
}

It's not quite *that* easy! I want to refresh the dataset if the even
triggering the page load is anything but an update. It could be a
postback for some other reason.

Is there a way to see, in the Page_Load method, the specific control
that triggered the postback. In other words,

private void Page_Load(object o, EventArgs e){
if (**Event calling this page is not the update button from
datagrid1**)
{
UpdateDataSet();
}
}

I have several controls on this page, and I want to make sure that the
dataset is refreshed in all circumstances, except when the user has
just clicked update.

Thanks.
 
S

Sam

You can add a little javascript on the onclick handler of the update
button to change the value of a hidden field on the page and you can
check *that* in page load.

I just did a whole navigation system that relies on this method.

Many of us wish we could get the postback args in page load.
Sometimes I think that if a couple of us got in a room together for
three hours we could design something better than Microsoft.

-Sam

PS Could you check the __EVENT_TARGET in the forms collection to see
if it looked like your update buttons? Just a thought.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top