Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > ASP.Net > Bind button to sql data source.

Thread Tools Display Modes
Old 04-25-2007, 07:43 AM
Specktur's Avatar
Specktur Specktur is offline
Join Date: Mar 2002
Location: Chicago, IL
Posts: 67
Default Bind button to sql data source.

Good morning,

I have a question, I am developing a web app, I have a grid view and a button, i would like to bind the enabled property of the button to a field in my sql data source.

So if the datasource field has a value of "true" I want the buttons enabled property to be false and vice versa.

Any ideas???

I'm a beginner to asp so be gentle...

Reply With Quote
Old 04-25-2007, 08:48 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636

Note you are also dealing with postbacks in a web environment. Controls will not be re-rendered per say, until a postback has been conducted on the server. With that being said, the value of "true" will exist in some row in some column. Will the query always return true or false for an entire column?

How are you populating the GridView? Are you using a SQL or ObjectDatabase? If so, on Page load or postback ASP.net under the covers is reloading the assigned query. Or are you populating the Grid programmatically through some sub routine?

If you are using the SQLDataSource and basically letting ASP.net do the data load for you, you can write code in the Selected() event, or basically after the query has fetched the data from the server and evaluate your process there.

 btnTarget.Enabled = Convert.ToBoolean(<the target column or cell value>)
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..