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