Help with GridView

M

MitchW

Hello,

I am am having trouble with the GridView control in conjunction with a
SQLDataSource control with ASP .NET 3.5 and C#. When the form loads I want
the current GirdView to only display information from the logged in user. (I
can do this with a SessionParameter no problem). Now I would like a button on
the form that removes the parameter so that all records are shown. This is
whew my problem come in. I could not figure out a way to do it so I thought I
would create the SelectCommand in C# code and change the select command based
on whether or not the box was checked or not. This works, except when I use
paging or when I click a sort column, then no record are returned.

Somehow it appears it is losing the SelectCommand altogether.

I would prefer not to use a FilterParameter as the dataset is very large.
What am I missing?

thanks in advance,
mitch
 
E

Eliyahu Goldin

Add another parameter to the SelectParameters:
<SelectParameters>
....
<asp:controlparameter name="GetAll" controlid="checkboxShowAll"
propertyname="Checked"/>
</SelectParameters>

Modify your select to have something like
WHERE user_id = @UserId or @GetAll = 1

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
M

MitchW

Eliyahu,

Thanks, but that will not work. The userid field is always populated with a
userid. What I need is a way of saying retrieve all user id's, not just a
specific one. I am unable to redesign the database so the only way I can see
getting around this is having a way to selectively turn on/off (apply/remove)
a select parameter.

thanks,
mitch

Eliyahu Goldin said:
Add another parameter to the SelectParameters:
<SelectParameters>
....
<asp:controlparameter name="GetAll" controlid="checkboxShowAll"
propertyname="Checked"/>
</SelectParameters>

Modify your select to have something like
WHERE user_id = @UserId or @GetAll = 1

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


MitchW said:
Hello,

I am am having trouble with the GridView control in conjunction with a
SQLDataSource control with ASP .NET 3.5 and C#. When the form loads I want
the current GirdView to only display information from the logged in user.
(I
can do this with a SessionParameter no problem). Now I would like a button
on
the form that removes the parameter so that all records are shown. This is
whew my problem come in. I could not figure out a way to do it so I
thought I
would create the SelectCommand in C# code and change the select command
based
on whether or not the box was checked or not. This works, except when I
use
paging or when I click a sort column, then no record are returned.

Somehow it appears it is losing the SelectCommand altogether.

I would prefer not to use a FilterParameter as the dataset is very large.
What am I missing?

thanks in advance,
mitch
 
E

Eliyahu Goldin

The "or @GetAll = 1" part will retrieve all user ids. If @GetAll = 1, all
records will be retrieved regardless their user_id value.


--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


MitchW said:
Eliyahu,

Thanks, but that will not work. The userid field is always populated with
a
userid. What I need is a way of saying retrieve all user id's, not just a
specific one. I am unable to redesign the database so the only way I can
see
getting around this is having a way to selectively turn on/off
(apply/remove)
a select parameter.

thanks,
mitch

Eliyahu Goldin said:
Add another parameter to the SelectParameters:
<SelectParameters>
....
<asp:controlparameter name="GetAll" controlid="checkboxShowAll"
propertyname="Checked"/>
</SelectParameters>

Modify your select to have something like
WHERE user_id = @UserId or @GetAll = 1

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


MitchW said:
Hello,

I am am having trouble with the GridView control in conjunction with a
SQLDataSource control with ASP .NET 3.5 and C#. When the form loads I
want
the current GirdView to only display information from the logged in
user.
(I
can do this with a SessionParameter no problem). Now I would like a
button
on
the form that removes the parameter so that all records are shown. This
is
whew my problem come in. I could not figure out a way to do it so I
thought I
would create the SelectCommand in C# code and change the select command
based
on whether or not the box was checked or not. This works, except when I
use
paging or when I click a sort column, then no record are returned.

Somehow it appears it is losing the SelectCommand altogether.

I would prefer not to use a FilterParameter as the dataset is very
large.
What am I missing?

thanks in advance,
mitch
 
M

MitchW

Eliyahu,

Thanks. Sorry I didn't see the OR.

--mitch

Eliyahu Goldin said:
The "or @GetAll = 1" part will retrieve all user ids. If @GetAll = 1, all
records will be retrieved regardless their user_id value.


--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


MitchW said:
Eliyahu,

Thanks, but that will not work. The userid field is always populated with
a
userid. What I need is a way of saying retrieve all user id's, not just a
specific one. I am unable to redesign the database so the only way I can
see
getting around this is having a way to selectively turn on/off
(apply/remove)
a select parameter.

thanks,
mitch

Eliyahu Goldin said:
Add another parameter to the SelectParameters:
<SelectParameters>
....
<asp:controlparameter name="GetAll" controlid="checkboxShowAll"
propertyname="Checked"/>
</SelectParameters>

Modify your select to have something like
WHERE user_id = @UserId or @GetAll = 1

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Hello,

I am am having trouble with the GridView control in conjunction with a
SQLDataSource control with ASP .NET 3.5 and C#. When the form loads I
want
the current GirdView to only display information from the logged in
user.
(I
can do this with a SessionParameter no problem). Now I would like a
button
on
the form that removes the parameter so that all records are shown. This
is
whew my problem come in. I could not figure out a way to do it so I
thought I
would create the SelectCommand in C# code and change the select command
based
on whether or not the box was checked or not. This works, except when I
use
paging or when I click a sort column, then no record are returned.

Somehow it appears it is losing the SelectCommand altogether.

I would prefer not to use a FilterParameter as the dataset is very
large.
What am I missing?

thanks in advance,
mitch
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top