How can I keep the dropdownlist from populating my gridview?

N

needin4mation

I have a gridview and a dropdownlist. If I change the ddl, the
gridview populates. That is what I want. But what I don't want is for
it to happen the first time they get to the page. I know I can add a
"Select Item," but is that the correct way to do it? I don't want it
to hit the database at all the first time the page loads. I have done
everything through visual studio and was trying to see if I could do
this with no code behind. Thanks.
 
N

needin4mation

So I cannot do this solely using the GUI? I will have to code it in
the page_load? Thanks.


Eliyahu said:
You need to check page property IsPostBack.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


I have a gridview and a dropdownlist. If I change the ddl, the
gridview populates. That is what I want. But what I don't want is for
it to happen the first time they get to the page. I know I can add a
"Select Item," but is that the correct way to do it? I don't want it
to hit the database at all the first time the page loads. I have done
everything through visual studio and was trying to see if I could do
this with no code behind. Thanks.
 
E

Eliyahu Goldin

Yes.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


So I cannot do this solely using the GUI? I will have to code it in
the page_load? Thanks.


Eliyahu said:
You need to check page property IsPostBack.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


I have a gridview and a dropdownlist. If I change the ddl, the
gridview populates. That is what I want. But what I don't want is for
it to happen the first time they get to the page. I know I can add a
"Select Item," but is that the correct way to do it? I don't want it
to hit the database at all the first time the page loads. I have done
everything through visual studio and was trying to see if I could do
this with no code behind. Thanks.
 
N

needin4mation

Here's my problem. Since I put everything in the front I'm not sure
what to put in the page behind. It's got the objectdatasource control
in the "regular" .aspx page.

How can I tell the grid not to fire if all the "stuff" is in the .aspx
file?


Eliyahu said:
Yes.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


So I cannot do this solely using the GUI? I will have to code it in
the page_load? Thanks.


Eliyahu said:
You need to check page property IsPostBack.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


I have a gridview and a dropdownlist. If I change the ddl, the
gridview populates. That is what I want. But what I don't want is for
it to happen the first time they get to the page. I know I can add a
"Select Item," but is that the correct way to do it? I don't want it
to hit the database at all the first time the page loads. I have done
everything through visual studio and was trying to see if I could do
this with no code behind. Thanks.
 
E

Eliyahu Goldin

Are you asking how to add some code to an aspx page? You can add a
service-side script to the aspx page. Would you call it "in the front"? You
can't use asp.net without writing a line of code. This is a sort of
professional technology, it needs a professional approach.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


Here's my problem. Since I put everything in the front I'm not sure
what to put in the page behind. It's got the objectdatasource control
in the "regular" .aspx page.

How can I tell the grid not to fire if all the "stuff" is in the .aspx
file?


Eliyahu said:
Yes.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


So I cannot do this solely using the GUI? I will have to code it in
the page_load? Thanks.


Eliyahu Goldin wrote:
You need to check page property IsPostBack.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


I have a gridview and a dropdownlist. If I change the ddl, the
gridview populates. That is what I want. But what I don't want is
for
it to happen the first time they get to the page. I know I can add
a
"Select Item," but is that the correct way to do it? I don't want
it
to hit the database at all the first time the page loads. I have
done
everything through visual studio and was trying to see if I could do
this with no code behind. Thanks.
 
N

needin4mation

No, I guess I wasn't clear. Sorry. I don't mind coding. I shouldn't
have to in this case, at least I thought.

I ended up being right and half right to begin with. I added an item
to my dropdownlist (-- select item --) and then set the value to -1, as
there is no -1 in my database. I then set the AppendDataBoundItems
setting in the dropdownlist to true so that the new --select item--
wouldn't be lost when the dropdownlist was populated by items from the
database. No coding beyond the .aspx page necessary.

Eliyahu said:
Are you asking how to add some code to an aspx page? You can add a
service-side script to the aspx page. Would you call it "in the front"? You
can't use asp.net without writing a line of code. This is a sort of
professional technology, it needs a professional approach.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


Here's my problem. Since I put everything in the front I'm not sure
what to put in the page behind. It's got the objectdatasource control
in the "regular" .aspx page.

How can I tell the grid not to fire if all the "stuff" is in the .aspx
file?


Eliyahu said:
Yes.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


So I cannot do this solely using the GUI? I will have to code it in
the page_load? Thanks.


Eliyahu Goldin wrote:
You need to check page property IsPostBack.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


I have a gridview and a dropdownlist. If I change the ddl, the
gridview populates. That is what I want. But what I don't want is
for
it to happen the first time they get to the page. I know I can add
a
"Select Item," but is that the correct way to do it? I don't want
it
to hit the database at all the first time the page loads. I have
done
everything through visual studio and was trying to see if I could do
this with no code behind. Thanks.
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top