Bind button to sql data source.

04-25-2007, 07:43 AM
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...


04-25-2007, 08:48 AM
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 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 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>)


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum