ok, 2 issues

G

Guest

Ok, I have my first full blown .NET 05 web application 99.9% complete except
for these 2 issues. can anyone help me out?

1) If a page gets and error and the user clicks on the menu it takes them
back to the login screen. How can I prevent that from happening? If they see
the 'user friendly" error page I want them to be able to click another menu
option and go to that page without going back to the login screen. (I'm not
using the membership provider for this app)

2) on several of my pages I have several drop downs and a button. When the
user makes a selection from a drop down and clicks the button, it loads the
..NET gridView. Now I need these grids sortable. How can I accomplish this?
a) I'm NOT using an SQLObjectDataSource to bind my grid
b) if I load my grid without any drop downs I can sort, its the
grids that load
based off of a drop down selection

example:
void GetSales(string lastName)
{
binds grid based off of the last name
can't sort grid when using this
}

BUT if i do
void GetSales()
{
binds grids and I can sort the gridview
}

need help on these. thanks
 
C

Cowboy \(Gregory A. Beamer\)

1. Have the page as an ASPX page instead of HTML and part of the
application. You might want to set up your own error handler in the Error
event in Global.asax that points to the ASPX error page.

2. Set up a routine that returns the dataSet to bind to teh grid. Have this
routine take the column to sort on, very similar to the samples that ship
with the SDK. Rebind after every sort click. If you do not reset your panels
(form and grid) on each click, viewstate will hold their state.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
 
S

Steven Cheng[MSFT]

Hello igotyourdotnet,

As for your first question, I've also found your another thread "error
trapping" in this newsgroup and some other members and our engineer Walter
have also joined in that thread. Normally, redirect to login page is caused
by the current user's associated role doesn't meet the ASP.NET(forms
authenticatino)'s authorization requirement. Is the menuitem(on the error
page) point to a page which require higher authorization permission? You
can try Gregory's suggestion on use a static html page to verify the
behavior.

As for the second question, I think basically, we can consider the
following options in ASP.NET 2.0 databinding page:

** If you do not use DataSource control to bind data to GridView, we need
to manually bind DataSource object to GridView.DataSource property
programmtically. Also, we should handle GridView.Sort event and rebind the
GridView with the sorted datasource collection. This is just like what we
do in ASP.NET 1.1 for DataGrid.

As for the Sorted DataSource object, I suggest you consider caching a
DataTable of the original data in ASP.NET cache, and when the Gridview's
Sort event fires, you retrieve the DataTable from cache and get a Sorted
DataView from the DataTable. This can help reduce the time we query the
backend database.

#GridView.Sorting Event
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.
sorting.aspx

Please let me know how you get the datasource object and what's the
datasource object collection so that we can provide some further info
according to the scenario.

** Since you mentioned that you use several dropdownlists to filter the
data retrieved from database and bind them to GridView, how do those
dropdownlist's filter items work in the select query? When using
Datasource Control(SqlDataSource or ObjectDataSource) we can also configure
the DataSource control to receive paramters from other controls(like
dropdownlist, textbox .....). Therefore, if it is possible to change your
page to use those dropdownlist as paramter source of Datasource control, we
can still bind GridView to datasource control and avoid manual sorting.

Please feel free to let me know if you have any particular concerns or
difficulties here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

1 - all of my pages are aspx pages I have not HTML/HTM pages in my project at
all.

2 - I'm doing that but the grid does not sort, when I click on a row to sort
 
G

Guest

thanks, that example is using a SQLObjectDataSource, where I'm not.
and my method to bind my grid takes parameters to get the data back from the
database
 
S

Steven Cheng[MSFT]

Thanks for your reply igotyourdotnet,

Yes, the MSDN reference's example is using datasource control. Also, based
on my further research, I found that the GridView's enchanded sorting
functions are naturally designed for using Datasource control. (you can
find that the Sort method and the GridView.SortExpression and SortDirection
property are useful only when we bind Gridview with a datasource control).

However, we can still do the sorting completely without using DataSource
control(though it would be much more complex). We need to do databinding
in the Sorting event , we also need to manually record the sortexpression
and sortdirection ourself and use them to create the Sorted DataView. I
have attached a sample page which programmtically query Database and return
a DataTable(use TableAdapter/typedDataTable) and then create sorted
DataView to databind the GridView. You can get the attachment through
outlook express. Or if you feel necessary I can email it to you.

The sample page is displaying the Product table's data in Northwind
database based on a CategoryID value which is selected through a
DropDownList.

In addition, since such programmatic approach loose the natural feature of
Gridview sorting, I suggset you consider create a custom DataAccess class
to encapsulate your data query and filtering code logic and use this class
in the ObjectDataSource so that you can make use of the GridView's default
sort behavior with objectdatasource. You can provide me the detailed info
about your page's data access logic and the helper classes, I can help
create a sample page on this if necessary.

Hope this helps. If there is anything unclear, please feel free to let me
know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Ok thanks

I'm using my web browser to view the newsgroups, can you email it to me at:
igotyourdotnet at gmail dotcom?

Also from what your describing I'm kind of doing but maybe I'm missing
something in the process.

I have my UI calling my business layer which returns a dataset or datatable
from my datalayer. In the datalayer I'm calling the database via a store
procedure. So when I get my data back its already coming back as I want it
but I just need to allow the user to sort the gridview on the client in case
they want to see the data differently.
 
S

Steven Cheng[MSFT]

Thanks for your reply igotyourdotnet,

Yes, I've send you a mail with the attached test pages. Also, my test pages
just use a TableAdapter/typedDataTable to simulate your business object
which return datatable. And manually bind the sorted DataView(create from
the returned DataTable) to the GridView . Also, I use code to
programmatically handle the GridView's Sorting event.

Please feel free to let me know if you have any questions on the test code
or other things.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top