473,395 Members | 1,484 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,395 software developers and data experts.

Creating SelectCommand at page load time

I have a need to change the select command based on user input (dropdown
lists 1 and 2). I'm using a GridView command that is tied to a
SqlDataSource command as follows:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MTT.mdfConnectionString %>" SelectCommand = "<%#
SQLWhereClause %>" >

</asp:SqlDataSource>

<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" runat="server"
CaptionAlign="Top" EnableSortingAndPagingCallbacks="True" Width="100%"
AutoGenerateColumns = "False" DataKeyNames="TipNumber">

<Columns>

<asp:HyperLinkField DataNavigateUrlFields="TipNumber"
DataNavigateUrlFormatString="Tip.aspx?Num={0}" DataTextField="TipNumber"
HeaderText="No." />

<asp:BoundField ReadOnly="True" HeaderText="Tip Name" InsertVisible="False"
DataField="TipName" SortExpression="TipName"></asp:BoundField>

<asp:BoundField ReadOnly="True" HeaderText="Teaser" InsertVisible="False"
DataField="TipSuffix" SortExpression="TipSuffix"></asp:BoundField>

</Columns>

</asp:GridView>

What I am attempting to do is create the SelectCommand via a Page_Load sub
as follows:

Protected Sub Page_load()

Dim SQLWhereClause As String = ""

SQLWhereClause = "SELECT * FROM [forum_tips] WHERE "

etc.

I build the String and end the Sub. I have verified that the value of
SQLWhereClause is what I want it to be but the GridView renders nothing as a
result (just as if it didn't have a select command.)

What am I doing wrong, please?1


Dec 1 '07 #1
1 1363
Great help, sir. I used a slightly different approach but your advice led
the way.

Jim

"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:6C**********************************@microsof t.com...
Howdy James,

It's just a coincidence as I have solved similar problem recently :) VS
debugger and Reflector helped to realise SelectCommand is not stored in
the
viewstate and it's set before Selecting event, so the only place you can
amend its value is Command property. So as you see it's just a matter of
investigation :)

Take care!
--
Milosz

Dec 2 '07 #2

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

Similar topics

1
by: Shelby | last post by:
Problem: My company generates its own data export from a propietary database. These (free) tables can be read in C#.NET using a Visual FoxPro driver (vfpoledb). I can read each of the six tables...
1
by: Hasani \(remove nospam\) | last post by:
The way the system works is, you create a user control (ascx) that will be a template and must implement the interface IPageTemplate. You then create one or more user controls (ascx) that implement...
0
by: Andrew Westgarth | last post by:
Hi all, i'm struggling with a page idea I have. I need to write a page with an A to Z list of available schools in the area. I only want to display the letters in the A to Z which have school...
4
by: Coleen | last post by:
Hi All :-) Can anyone give me a URL where I can find a good example of code on how to create a temporary SQL table using VB.net? I've checked the Microsoft site at: ...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
1
by: David Lozzi | last post by:
Hello, I'm wondering whats the best method to use for displaying several photos' thumbnails. One method I know is to dynamically resize the photo at the time the page is loaded. What does this...
8
by: dd | last post by:
Has anyone found a way around the problem IE has if you create elements (script or div, doesn't seem to matter) BEFORE the document.readyState is "complete" ? I know you can sometimes get away...
1
by: John Kotuby | last post by:
Hello again... I have tried using the SQLDatsource control as part of a user control that just conatins a Repeater and the SQLDatasource control which is designated as the Datsource for the...
0
MrMancunian
by: MrMancunian | last post by:
How to create a database connection without using wizards Introduction I've seen a lot of questions on the net about getting data from, and saving data to databases. Here's a little insight how...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.