473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Generalized filtering with GridView and SqlDataSource

I have a Gridview displaying the results of a stored procedure. The
stored procedure is constantly changing so the columns displayed in the
data grid are constantly changing. I'd like to give users the ability
to filter by the value of any column. This is easily done using the
FilterExpression property of the DataSource. However, prior to
creating the filter expression, I need to know if the column they wish
to filter contains text or numerical values (basically do I surround
the value to filter for in quotes or not.) Is there any way to
determine the data type of the underlying data column?
Any help would be greatly appreciated.

Jan 9 '07 #1
2 2202
To get info on columns, you need to get the schema. With SqlDataSource you
can get to the schema if you first get to the datatable. This article
explains how you can get the datatable out of SqlDataSource:
http://msmvps.com/blogs/egoldin/arch...atasource.aspx

Once you have the datatable, its Columns collection will take you to the
column. Column.DataType property will tell your the type of the column. You
can apply filtering to the datatable rather that to the datasource. It will
save you a trip to the database. DataTable.Select can return a filtered
array of rows and you can databind the grid to this array.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<ke*******@yahoo.comwrote in message
news:11**********************@11g2000cwr.googlegro ups.com...
>I have a Gridview displaying the results of a stored procedure. The
stored procedure is constantly changing so the columns displayed in the
data grid are constantly changing. I'd like to give users the ability
to filter by the value of any column. This is easily done using the
FilterExpression property of the DataSource. However, prior to
creating the filter expression, I need to know if the column they wish
to filter contains text or numerical values (basically do I surround
the value to filter for in quotes or not.) Is there any way to
determine the data type of the underlying data column?
Any help would be greatly appreciated.

Jan 9 '07 #2

Thanks for your quick answer! That helped.

Jan 10 '07 #3

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

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
2
by: Bill Manring | last post by:
I am writing a very simple web application using VS 2005 and a SQL Server Database. I am just starting to experiment wth .NET 2.0 and I am trying out the supposedly improved databinding. I...
0
by: Mike P | last post by:
Where exactly are the updateparameters of a gridview picked up from? I have created 2 very similar gridviews and given the updateparameters the same names as in my edititemtemplates. Yet this...
0
by: kurt.craver | last post by:
I have a component control that I created as a UserControl which contains a SqlDataSource control, a GridView control, a DropDownList control, a TextBox control, and a Button control. The idea is...
0
by: LiamLiamLiam | last post by:
G'day all. I having a problem with my formview. I'll ty to explain my situation as best as i can. I have a page with a search field at the top which is just a simple asp:textbox. Below that i...
4
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy just wanted easy UI to make updates. When I select ‘Edit’, I get the fields I want to edit. I edit them and click...
0
by: lamolap | last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel) my gidview looks like this Edit Surname Initials ...
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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,...

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.