473,513 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page_Load

Hi.

I have a button called btnSelect on a web form. There is a handler for it.
However, the Page_Load() gets called before the handler gets called.

I want to do the following. In the Page_Load(), I want to check if the
btnSelect caused the event. How can I do this?

Please help.

--
Be Cool!
Jul 21 '05 #1
16 1873
Take a look at the values available int Request object; you should be able
to find the information you need because all the information send by the
POST submission of the form is there.

However, I'm not sure is this is the right thing to do. Instead, you should
isolate the relevant code in a subroutine and call it from the btnSelect
event.

S. L.

"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
Hi.

I have a button called btnSelect on a web form. There is a handler for
it.
However, the Page_Load() gets called before the handler gets called.

I want to do the following. In the Page_Load(), I want to check if the
btnSelect caused the event. How can I do this?

Please help.

--
Be Cool!

Jul 21 '05 #2
Yes. You are right about the form submission with the post. I can get the
information. However, this is a little different story.

This has more to do with postback and capturing events.

The question is, "How do I check what object caused this event for it to
come to Page_Load()?".

Please help.

"Sylvain Lafontaine" wrote:
Take a look at the values available int Request object; you should be able
to find the information you need because all the information send by the
POST submission of the form is there.

However, I'm not sure is this is the right thing to do. Instead, you should
isolate the relevant code in a subroutine and call it from the btnSelect
event.

S. L.

"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
Hi.

I have a button called btnSelect on a web form. There is a handler for
it.
However, the Page_Load() gets called before the handler gets called.

I want to do the following. In the Page_Load(), I want to check if the
btnSelect caused the event. How can I do this?

Please help.

--
Be Cool!


Jul 21 '05 #3
I'm sorry, but I don't know the answer to your question.

Maybe the following article will give you a starting point for your
research:
http://msdn.microsoft.com/library/de...bjectmodel.asp

S. L.

"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
Yes. You are right about the form submission with the post. I can get
the
information. However, this is a little different story.

This has more to do with postback and capturing events.

The question is, "How do I check what object caused this event for it to
come to Page_Load()?".

Please help.

"Sylvain Lafontaine" wrote:
Take a look at the values available int Request object; you should be
able
to find the information you need because all the information send by the
POST submission of the form is there.

However, I'm not sure is this is the right thing to do. Instead, you
should
isolate the relevant code in a subroutine and call it from the btnSelect
event.

S. L.

"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
> Hi.
>
> I have a button called btnSelect on a web form. There is a handler
> for
> it.
> However, the Page_Load() gets called before the handler gets called.
>
> I want to do the following. In the Page_Load(), I want to check if the
> btnSelect caused the event. How can I do this?
>
> Please help.
>
> --
> Be Cool!


Jul 21 '05 #4
Hi

The loadevent is called everytime a page is loaded or/and is postedback

There is no need to check in that page the handling of the button event,
that you can do in the button click event it self (when you do not know
that, than message back)

For to prevent that unwanted actions are taken on postback is the IsPostback
property, very easy to use and well desctripted on this page.
http://msdn.microsoft.com/library/de...tbacktopic.asp

I hope this helps?

Merry Christmas

Cor
Jul 21 '05 #5
Cor,

Here is my problem. I have a datagrid with sort columns. One of those
columns is a checkbox column. And, I have a button regular button with
postback.

My page_load() looks something like this:

void page_load(..)
{
If (!IsPostBack)
{
Session["SortColumn"] = "AgentID";
Session["SortOrder"] = "Asc";
}

BindData();
}

When I click on a column header, it sorts by the sort order. So, I need to
call BindData(). When I click on a button called "Select", I don't need to
call BindData() and display the checkboxes that are checked prior to pressing
the button. I do have the button handler, but the Page_Load is called before
the handler gets called.

I need to determine if the original event is caused by the button or
something else in order to prevent the datagrid binding data every time.

Your input is appreciated.

J

"Cor Ligthert" wrote:
Hi

The loadevent is called everytime a page is loaded or/and is postedback

There is no need to check in that page the handling of the button event,
that you can do in the button click event it self (when you do not know
that, than message back)

For to prevent that unwanted actions are taken on postback is the IsPostback
property, very easy to use and well desctripted on this page.
http://msdn.microsoft.com/library/de...tbacktopic.asp

I hope this helps?

Merry Christmas

Cor

Jul 21 '05 #6
J,

Probably when you see this than you think something as Ohhhh me

My page_load() looks something like this:

void page_load(..)
{
If (!IsPostBack)
{
Session["SortColumn"] = "AgentID";
Session["SortOrder"] = "Asc";

BindData();
}
}

And you do the BindData() as normal in your clickevent at the time when it
should be done.

I hope this helps?

Cor
Jul 21 '05 #7
Cor is right. Move BindData into your if statement and then call it as
needed in the click event for the column sort.
Then, when the user clicks select, you won't run into a BindData call along
the way.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
Cor,

Here is my problem. I have a datagrid with sort columns. One of those
columns is a checkbox column. And, I have a button regular button with
postback.

My page_load() looks something like this:

void page_load(..)
{
If (!IsPostBack)
{
Session["SortColumn"] = "AgentID";
Session["SortOrder"] = "Asc";
}

BindData();
}

When I click on a column header, it sorts by the sort order. So, I need to call BindData(). When I click on a button called "Select", I don't need to call BindData() and display the checkboxes that are checked prior to pressing the button. I do have the button handler, but the Page_Load is called before the handler gets called.

I need to determine if the original event is caused by the button or
something else in order to prevent the datagrid binding data every time.

Your input is appreciated.

J

"Cor Ligthert" wrote:
Hi

The loadevent is called everytime a page is loaded or/and is postedback

There is no need to check in that page the handling of the button event,
that you can do in the button click event it self (when you do not know
that, than message back)

For to prevent that unwanted actions are taken on postback is the IsPostback property, very easy to use and well desctripted on this page.
http://msdn.microsoft.com/library/de...tbacktopic.asp
I hope this helps?

Merry Christmas

Cor

Jul 21 '05 #8
Aha! It's a good try, but here is something to consider. If I move the
BindData() to the !IsPostBack section, and then, I press a column header, it
won't show any data because BindData() isn't being called. SOmehow, I need
to prevent BindData() only when it is caused by the "select" button.

J

"Nick Malik [Microsoft]" wrote:
Cor is right. Move BindData into your if statement and then call it as
needed in the click event for the column sort.
Then, when the user clicks select, you won't run into a BindData call along
the way.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
Cor,

Here is my problem. I have a datagrid with sort columns. One of those
columns is a checkbox column. And, I have a button regular button with
postback.

My page_load() looks something like this:

void page_load(..)
{
If (!IsPostBack)
{
Session["SortColumn"] = "AgentID";
Session["SortOrder"] = "Asc";
}

BindData();
}

When I click on a column header, it sorts by the sort order. So, I need

to
call BindData(). When I click on a button called "Select", I don't need

to
call BindData() and display the checkboxes that are checked prior to

pressing
the button. I do have the button handler, but the Page_Load is called

before
the handler gets called.

I need to determine if the original event is caused by the button or
something else in order to prevent the datagrid binding data every time.

Your input is appreciated.

J

"Cor Ligthert" wrote:
Hi

The loadevent is called everytime a page is loaded or/and is postedback

There is no need to check in that page the handling of the button event,
that you can do in the button click event it self (when you do not know
that, than message back)

For to prevent that unwanted actions are taken on postback is the IsPostback property, very easy to use and well desctripted on this page.
http://msdn.microsoft.com/library/de...tbacktopic.asp
I hope this helps?

Merry Christmas

Cor


Jul 21 '05 #9
Oh, OK. I mis-uderstood earlier. That may work. LEt me try it and get back
to this.

Thanks much.

"thejackofall" wrote:
Aha! It's a good try, but here is something to consider. If I move the
BindData() to the !IsPostBack section, and then, I press a column header, it
won't show any data because BindData() isn't being called. SOmehow, I need
to prevent BindData() only when it is caused by the "select" button.

J

"Nick Malik [Microsoft]" wrote:
Cor is right. Move BindData into your if statement and then call it as
needed in the click event for the column sort.
Then, when the user clicks select, you won't run into a BindData call along
the way.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
Cor,

Here is my problem. I have a datagrid with sort columns. One of those
columns is a checkbox column. And, I have a button regular button with
postback.

My page_load() looks something like this:

void page_load(..)
{
If (!IsPostBack)
{
Session["SortColumn"] = "AgentID";
Session["SortOrder"] = "Asc";
}

BindData();
}

When I click on a column header, it sorts by the sort order. So, I need

to
call BindData(). When I click on a button called "Select", I don't need

to
call BindData() and display the checkboxes that are checked prior to

pressing
the button. I do have the button handler, but the Page_Load is called

before
the handler gets called.

I need to determine if the original event is caused by the button or
something else in order to prevent the datagrid binding data every time.

Your input is appreciated.

J

"Cor Ligthert" wrote:

> Hi
>
> The loadevent is called everytime a page is loaded or/and is postedback
>
> There is no need to check in that page the handling of the button event,
> that you can do in the button click event it self (when you do not know
> that, than message back)
>
> For to prevent that unwanted actions are taken on postback is the

IsPostback
> property, very easy to use and well desctripted on this page.
>

http://msdn.microsoft.com/library/de...tbacktopic.asp
>
> I hope this helps?
>
> Merry Christmas
>
> Cor
>
>
>


Jul 21 '05 #10
Thanks for the suggestion. I did stick the BindData() in the !isPostBack
block. In the process, I learned that my columns were sorting only because
BindData() was called everytime. Since I moved BindData() into the
!IsPostBack block, my columns don't sort when I click on a column header. I
learned that TemplateColumn does not generate the sort event.

I need to be able to sort using the TemplateColumn. Please help.

Thanks
TheJackOfAll

"Cor Ligthert" wrote:
J,

Probably when you see this than you think something as Ohhhh me

My page_load() looks something like this:

void page_load(..)
{
If (!IsPostBack)
{
Session["SortColumn"] = "AgentID";
Session["SortOrder"] = "Asc";

BindData();
}
}

And you do the BindData() as normal in your clickevent at the time when it
should be done.

I hope this helps?

Cor

Jul 21 '05 #11
Thanks for the suggestion. I did stick the BindData() in the !isPostBack
block. In the process, I learned that my columns were sorting only because
BindData() was called everytime. Since I moved BindData() into the
!IsPostBack block, my columns don't sort when I click on a column header. I
learned that TemplateColumn does not generate the sort event.

Does anyone have any helpful information to sort when using TemplateColumn?

I need to be able to sort using the TemplateColumn. Please help.

Thanks
TheJackOfAll

"Nick Malik [Microsoft]" wrote:
Cor is right. Move BindData into your if statement and then call it as
needed in the click event for the column sort.
Then, when the user clicks select, you won't run into a BindData call along
the way.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
Cor,

Here is my problem. I have a datagrid with sort columns. One of those
columns is a checkbox column. And, I have a button regular button with
postback.

My page_load() looks something like this:

void page_load(..)
{
If (!IsPostBack)
{
Session["SortColumn"] = "AgentID";
Session["SortOrder"] = "Asc";
}

BindData();
}

When I click on a column header, it sorts by the sort order. So, I need

to
call BindData(). When I click on a button called "Select", I don't need

to
call BindData() and display the checkboxes that are checked prior to

pressing
the button. I do have the button handler, but the Page_Load is called

before
the handler gets called.

I need to determine if the original event is caused by the button or
something else in order to prevent the datagrid binding data every time.

Your input is appreciated.

J

"Cor Ligthert" wrote:
Hi

The loadevent is called everytime a page is loaded or/and is postedback

There is no need to check in that page the handling of the button event,
that you can do in the button click event it self (when you do not know
that, than message back)

For to prevent that unwanted actions are taken on postback is the IsPostback property, very easy to use and well desctripted on this page.
http://msdn.microsoft.com/library/de...tbacktopic.asp
I hope this helps?

Merry Christmas

Cor


Jul 21 '05 #12
Jack,

On what other places did you do the databind, because you have probably to
do the databind in most of your events.

From your post I am still not sure you do that?

Show us some more code, especially from an event where you do some actions
with your sortcode session.

Cor
Jul 21 '05 #13
both Cor and I asked you to move the BindData into the PostBack and then
ALSO call BindData in each of the events where you want the sort to occur.

I'm not sure that you understood that.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
Thanks for the suggestion. I did stick the BindData() in the !isPostBack
block. In the process, I learned that my columns were sorting only because BindData() was called everytime. Since I moved BindData() into the
!IsPostBack block, my columns don't sort when I click on a column header. I learned that TemplateColumn does not generate the sort event.

Does anyone have any helpful information to sort when using TemplateColumn?
I need to be able to sort using the TemplateColumn. Please help.

Thanks
TheJackOfAll

"Nick Malik [Microsoft]" wrote:
Cor is right. Move BindData into your if statement and then call it as
needed in the click event for the column sort.
Then, when the user clicks select, you won't run into a BindData call along
the way.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
Cor,

Here is my problem. I have a datagrid with sort columns. One of those columns is a checkbox column. And, I have a button regular button with postback.

My page_load() looks something like this:

void page_load(..)
{
If (!IsPostBack)
{
Session["SortColumn"] = "AgentID";
Session["SortOrder"] = "Asc";
}

BindData();
}

When I click on a column header, it sorts by the sort order. So, I need
to
call BindData(). When I click on a button called "Select", I don't
need to
call BindData() and display the checkboxes that are checked prior to

pressing
the button. I do have the button handler, but the Page_Load is called

before
the handler gets called.

I need to determine if the original event is caused by the button or
something else in order to prevent the datagrid binding data every

time.
Your input is appreciated.

J

"Cor Ligthert" wrote:

> Hi
>
> The loadevent is called everytime a page is loaded or/and is postedback >
> There is no need to check in that page the handling of the button event, > that you can do in the button click event it self (when you do not know > that, than message back)
>
> For to prevent that unwanted actions are taken on postback is the

IsPostback
> property, very easy to use and well desctripted on this page.
>

http://msdn.microsoft.com/library/de...tbacktopic.asp
>
> I hope this helps?
>
> Merry Christmas
>
> Cor
>
>
>


Jul 21 '05 #14
Yes. You are right about the approach. And, I did exactly what you guys
said. My problem, now is that I am using TemplateColumns, and the
TemplateColumn does not generate the event I need to do the sorting.

Thanks.
TheJackOfAll

"Nick Malik [Microsoft]" wrote:
both Cor and I asked you to move the BindData into the PostBack and then
ALSO call BindData in each of the events where you want the sort to occur.

I'm not sure that you understood that.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
Thanks for the suggestion. I did stick the BindData() in the !isPostBack
block. In the process, I learned that my columns were sorting only

because
BindData() was called everytime. Since I moved BindData() into the
!IsPostBack block, my columns don't sort when I click on a column header.

I
learned that TemplateColumn does not generate the sort event.

Does anyone have any helpful information to sort when using

TemplateColumn?

I need to be able to sort using the TemplateColumn. Please help.

Thanks
TheJackOfAll

"Nick Malik [Microsoft]" wrote:
Cor is right. Move BindData into your if statement and then call it as
needed in the click event for the column sort.
Then, when the user clicks select, you won't run into a BindData call along the way.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
> Cor,
>
> Here is my problem. I have a datagrid with sort columns. One of those > columns is a checkbox column. And, I have a button regular button with > postback.
>
> My page_load() looks something like this:
>
> void page_load(..)
> {
> If (!IsPostBack)
> {
> Session["SortColumn"] = "AgentID";
> Session["SortOrder"] = "Asc";
> }
>
> BindData();
> }
>
> When I click on a column header, it sorts by the sort order. So, I need to
> call BindData(). When I click on a button called "Select", I don't need to
> call BindData() and display the checkboxes that are checked prior to
pressing
> the button. I do have the button handler, but the Page_Load is called
before
> the handler gets called.
>
> I need to determine if the original event is caused by the button or
> something else in order to prevent the datagrid binding data every time. >
> Your input is appreciated.
>
> J
>
> "Cor Ligthert" wrote:
>
> > Hi
> >
> > The loadevent is called everytime a page is loaded or/and is postedback > >
> > There is no need to check in that page the handling of the button event, > > that you can do in the button click event it self (when you do not know > > that, than message back)
> >
> > For to prevent that unwanted actions are taken on postback is the
IsPostback
> > property, very easy to use and well desctripted on this page.
> >
http://msdn.microsoft.com/library/de...tbacktopic.asp > >
> > I hope this helps?
> >
> > Merry Christmas
> >
> > Cor
> >
> >
> >


Jul 21 '05 #15
Hi. I have a TemplateColumn with sorting. However, it does not fire the
sort event. Here is what I have. Please help.

<asp:TemplateColumn HeaderText="Wire ID"
SortExpression="WireID">
<itemtemplate>
<a href='<%# "Wire.aspx" + "?PackageID=" +
Request.QueryString["PackageID"] + "&WireID=" +
DataBinder.Eval(Container.DataItem, "WireID") + "&AgentID=" +
DataBinder.Eval(Container.DataItem, "AgentID") + "&CustomerType=" +
DataBinder.Eval(Container.DataItem, "CustomerType") %>'>
<%# DataBinder.Eval(Container.DataItem, "WireID") %>
</a>
</itemtemplate>
</asp:TemplateColumn>

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++

In the code behind,

private void InitializeComponent()
{
//this.lnkWireID = new LinkButton();
//this.lnkWireID.ID = "lnkWireID";

this.btnInclude.Click += new System.EventHandler(this.btnInclude_Click);
this.btnApprove.Click += new System.EventHandler(this.btnApprove_Click);
this.CustomerType.SelectedIndexChanged += new
System.EventHandler(this.CustomerType_SelectedInde xChanged);
this.DataGrid1.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.SortData);
this.Load += new System.EventHandler(this.Page_Load);

}

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++

private void SortData(Object sender, DataGridSortCommandEventArgs e)
{
Session["SortColumn"] = (string) e.SortExpression;
string sSortOrder = (string) Session["SortOrder"];

if (sSortOrder == " desc")
Session["SortOrder"] = " asc";
else
Session["SortOrder"] = " desc";

BindData();
}

Thanks
Jack
"thejackofall" wrote:
Yes. You are right about the approach. And, I did exactly what you guys
said. My problem, now is that I am using TemplateColumns, and the
TemplateColumn does not generate the event I need to do the sorting.

Thanks.
TheJackOfAll

"Nick Malik [Microsoft]" wrote:
both Cor and I asked you to move the BindData into the PostBack and then
ALSO call BindData in each of the events where you want the sort to occur.

I'm not sure that you understood that.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
Thanks for the suggestion. I did stick the BindData() in the !isPostBack
block. In the process, I learned that my columns were sorting only

because
BindData() was called everytime. Since I moved BindData() into the
!IsPostBack block, my columns don't sort when I click on a column header.

I
learned that TemplateColumn does not generate the sort event.

Does anyone have any helpful information to sort when using

TemplateColumn?

I need to be able to sort using the TemplateColumn. Please help.

Thanks
TheJackOfAll

"Nick Malik [Microsoft]" wrote:

> Cor is right. Move BindData into your if statement and then call it as
> needed in the click event for the column sort.
> Then, when the user clicks select, you won't run into a BindData call

along
> the way.
>
> --
> --- Nick Malik [Microsoft]
> MCSD, CFPS, Certified Scrummaster
> http://blogs.msdn.com/nickmalik
>
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a
> programmer helping programmers.
> --
> "thejackofall" <th**********@discussions.microsoft.com> wrote in message
> news:7B**********************************@microsof t.com...
> > Cor,
> >
> > Here is my problem. I have a datagrid with sort columns. One of

those
> > columns is a checkbox column. And, I have a button regular button

with
> > postback.
> >
> > My page_load() looks something like this:
> >
> > void page_load(..)
> > {
> > If (!IsPostBack)
> > {
> > Session["SortColumn"] = "AgentID";
> > Session["SortOrder"] = "Asc";
> > }
> >
> > BindData();
> > }
> >
> > When I click on a column header, it sorts by the sort order. So, I

need
> to
> > call BindData(). When I click on a button called "Select", I don't

need
> to
> > call BindData() and display the checkboxes that are checked prior to
> pressing
> > the button. I do have the button handler, but the Page_Load is called
> before
> > the handler gets called.
> >
> > I need to determine if the original event is caused by the button or
> > something else in order to prevent the datagrid binding data every

time.
> >
> > Your input is appreciated.
> >
> > J
> >
> > "Cor Ligthert" wrote:
> >
> > > Hi
> > >
> > > The loadevent is called everytime a page is loaded or/and is

postedback
> > >
> > > There is no need to check in that page the handling of the button

event,
> > > that you can do in the button click event it self (when you do not

know
> > > that, than message back)
> > >
> > > For to prevent that unwanted actions are taken on postback is the
> IsPostback
> > > property, very easy to use and well desctripted on this page.
> > >
>

http://msdn.microsoft.com/library/de...tbacktopic.asp
> > >
> > > I hope this helps?
> > >
> > > Merry Christmas
> > >
> > > Cor
> > >
> > >
> > >
>
>
>


Jul 21 '05 #16
Hi. I have a TemplateColumn with sorting. However, it does not fire the
sort event. Here is what I have. Please help.

<asp:TemplateColumn HeaderText="Wire ID"
SortExpression="WireID">
<itemtemplate>
<a href='<%# "Wire.aspx" + "?PackageID=" +
Request.QueryString["PackageID"] + "&WireID=" +
DataBinder.Eval(Container.DataItem, "WireID") + "&AgentID=" +
DataBinder.Eval(Container.DataItem, "AgentID") + "&CustomerType=" +
DataBinder.Eval(Container.DataItem, "CustomerType") %>'>
<%# DataBinder.Eval(Container.DataItem, "WireID") %>
</a>
</itemtemplate>
</asp:TemplateColumn>

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++

In the code behind,

private void InitializeComponent()
{
//this.lnkWireID = new LinkButton();
//this.lnkWireID.ID = "lnkWireID";

this.btnInclude.Click += new System.EventHandler(this.btnInclude_Click);
this.btnApprove.Click += new System.EventHandler(this.btnApprove_Click);
this.CustomerType.SelectedIndexChanged += new
System.EventHandler(this.CustomerType_SelectedInde xChanged);
this.DataGrid1.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.SortData);
this.Load += new System.EventHandler(this.Page_Load);

}

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++

private void SortData(Object sender, DataGridSortCommandEventArgs e)
{
Session["SortColumn"] = (string) e.SortExpression;
string sSortOrder = (string) Session["SortOrder"];

if (sSortOrder == " desc")
Session["SortOrder"] = " asc";
else
Session["SortOrder"] = " desc";

BindData();
}

Thanks
Jack
"thejackofall" wrote:
Yes. You are right about the approach. And, I did exactly what you guys
said. My problem, now is that I am using TemplateColumns, and the
TemplateColumn does not generate the event I need to do the sorting.

Thanks.
TheJackOfAll

"Nick Malik [Microsoft]" wrote:
both Cor and I asked you to move the BindData into the PostBack and then
ALSO call BindData in each of the events where you want the sort to occur.

I'm not sure that you understood that.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"thejackofall" <th**********@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
Thanks for the suggestion. I did stick the BindData() in the !isPostBack
block. In the process, I learned that my columns were sorting only

because
BindData() was called everytime. Since I moved BindData() into the
!IsPostBack block, my columns don't sort when I click on a column header.

I
learned that TemplateColumn does not generate the sort event.

Does anyone have any helpful information to sort when using

TemplateColumn?

I need to be able to sort using the TemplateColumn. Please help.

Thanks
TheJackOfAll

"Nick Malik [Microsoft]" wrote:

> Cor is right. Move BindData into your if statement and then call it as
> needed in the click event for the column sort.
> Then, when the user clicks select, you won't run into a BindData call

along
> the way.
>
> --
> --- Nick Malik [Microsoft]
> MCSD, CFPS, Certified Scrummaster
> http://blogs.msdn.com/nickmalik
>
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a
> programmer helping programmers.
> --
> "thejackofall" <th**********@discussions.microsoft.com> wrote in message
> news:7B**********************************@microsof t.com...
> > Cor,
> >
> > Here is my problem. I have a datagrid with sort columns. One of

those
> > columns is a checkbox column. And, I have a button regular button

with
> > postback.
> >
> > My page_load() looks something like this:
> >
> > void page_load(..)
> > {
> > If (!IsPostBack)
> > {
> > Session["SortColumn"] = "AgentID";
> > Session["SortOrder"] = "Asc";
> > }
> >
> > BindData();
> > }
> >
> > When I click on a column header, it sorts by the sort order. So, I

need
> to
> > call BindData(). When I click on a button called "Select", I don't

need
> to
> > call BindData() and display the checkboxes that are checked prior to
> pressing
> > the button. I do have the button handler, but the Page_Load is called
> before
> > the handler gets called.
> >
> > I need to determine if the original event is caused by the button or
> > something else in order to prevent the datagrid binding data every

time.
> >
> > Your input is appreciated.
> >
> > J
> >
> > "Cor Ligthert" wrote:
> >
> > > Hi
> > >
> > > The loadevent is called everytime a page is loaded or/and is

postedback
> > >
> > > There is no need to check in that page the handling of the button

event,
> > > that you can do in the button click event it self (when you do not

know
> > > that, than message back)
> > >
> > > For to prevent that unwanted actions are taken on postback is the
> IsPostback
> > > property, very easy to use and well desctripted on this page.
> > >
>

http://msdn.microsoft.com/library/de...tbacktopic.asp
> > >
> > > I hope this helps?
> > >
> > > Merry Christmas
> > >
> > > Cor
> > >
> > >
> > >
>
>
>


Jul 21 '05 #17

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

Similar topics

3
3932
by: Stevie_mac | last post by:
It might be me but... I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I do geta Page_Load event when an item on the ASPX (inside the iFrame) is clicked but then IsPostBack=False by now!. The ASPX is opened via client side script (into an iFrame) inside a .HTM file (as ASPX postback causes problems in a modal...
1
3365
by: bminder | last post by:
In the asp.net pages below, Common.vb has an overridable Page_Load sub. In the consuming page, Two.aspx, the Page_Load sub is inherited, but for some reason it (Overrides Sub Page_Load) executes twice. In another "regular" asp.net page that inherits only from its own codebehind page, the page load only executes once as you'd expect. Any...
3
1833
by: DavidS | last post by:
Have parent.aspx from which I open Driver.aspx form via button on parent.aspx. When I first open the modal dialog, the driver.aspx Page_Load function is called. After I close the dialog, then reopen the form again by clicking the button control from the parent - the Page_Load function is not called. parent.aspx <script block> function...
0
1607
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
14
13092
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) { //existing session? if (Session == null) { //save local empty order object this._newOrder = Orders.Initialize();
4
2346
by: tshad | last post by:
Is there a way to do put Page_loads on a page? I am trying to setup a Page_Load that just puts a persons name that is logged on at the top of a page the first time a page is loaded. In my template (which would be copied to each page) would have this in it. The each page has its own Page handling for the first time it is loaded, also...
4
3947
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques was endeavoring to create a custom user control to make things a bit simpler, but she noticed that her Page_Load eventhandler was firing twice. So...
5
3142
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits CommonPageBase - Contains myPage which inherits PageBase Each of these classes overrides OnInit and ties an event handler
1
2951
by: rockdale | last post by:
Hi, I have a masterpage and on the page_load event I Populate my mainmenu from database. I the page_load event of my content, I am trying to programmly select the menuitem that represent current content page, but as you know, the page_load event is fired backward, the content page_load fires first then followed by the master page...
11
2681
by: fiefie.niles | last post by:
I am using ASP.NET 2005 and I have a simple form. Page_Load calls a sub mySub that does not do anything (for testing purposes). But, Page_Load gets called twice. On every single ASPX page in my site, Page_Load gets called twice. Why is that and how can I fix this problem ? Thank you very much. Imports System.IO Namespace myProject...
0
7178
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...
0
7565
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...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
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...
0
5704
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4759
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...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
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...

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.