473,396 Members | 1,933 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.

Change Gridview Datasource or Select statement ijn code?

K B
Hi. I have a gridview with sqldatasource, etc. For the grid, I also have
a search textbox. If the user needs to filter the records, I want to
dynamically adjust the SELECT statement for the SqlDataSource. I like
all the automatic capabilities for paging, sorting, etc., so I don't
want to just bind the old way.

Any clues?

thanks,
KB

*** Sent via Developersdex http://www.developersdex.com ***
Jun 8 '06 #1
1 5976
On Wed, 07 Jun 2006 18:07:03 -0700, K B <ka**********@comcast.net>
wrote:
Hi. I have a gridview with sqldatasource, etc. For the grid, I also have
a search textbox. If the user needs to filter the records, I want to
dynamically adjust the SELECT statement for the SqlDataSource. I like
all the automatic capabilities for paging, sorting, etc., so I don't
want to just bind the old way.

Any clues?

thanks,
KB

*** Sent via Developersdex http://www.developersdex.com ***


The QuickStart's are a great resource for things like this. To change
your sql statement in a sqldatasource, use the SelectCommand
attribute. You can set it in code by doing something like:

SqlDataSource1.SelectCommand = "select * from table";

http://www.asp.net/QuickStart/util/s...ViewSimple.src

<%@ Page Language="C#" %>
<html>
<head runat="server">
<title>GridView Bound to SqlDataSource</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1"
runat="server" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand="SELECT [au_id], [au_lname], [au_fname], [phone],
[address], [city], [state], [zip], [contract] FROM [authors]"
ConnectionString="<%$ ConnectionStrings:Pubs %>" />
</form>
</body>
</html>
Peter Kellner
http://peterkellner.net
Jun 8 '06 #2

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

Similar topics

6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
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...
5
by: Mark Olbert | last post by:
I ran into a situation this morning where the RowUpdating event of a GridView kept insisting there were no entries in either the OldValues or NewValues dictionaries. The GridView is bound to a...
4
by: Dabbler | last post by:
I need to convert a CompanyId in one table to Company Name from another table for an ItemTemplate. I thought I would just add another SqlDataSource but not sure how to eval with the CompanyId...
0
by: Adam Sandler | last post by:
Hello, Prior to posting I looked at http://groups.google.com/group/ microsoft.public.dotnet.framework.aspnet/browse_thread/thread/ d8d5ae243614085e/d4fd6c4a5aa56f75 ...
0
by: Larry Bud | last post by:
After spending two days looking at the options in adding a row to a gridview, I came up with my own that I'd like to share. I only can share pseudo-code right now, but maybe in the future I'll...
1
by: Froefel | last post by:
I'm very new to the ADO.NET and WebForms arena, so the problem that I'm having is probably trivial. Using VS2005, I'm just creating a small test project that has a text box allowing you to enter...
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...
2
by: =?Utf-8?B?bWFnZ2ll?= | last post by:
hi, I have a gridview that is based on parameters. When the select statement does not return any rows, I want to display a label that says 'nothing found'. It works the first time there is not...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...
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
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.