Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set FormView mode depending on query results?

Status
Not open for further replies.

pbb72

Programmer
Mar 27, 2004
38
NO
Hi all,

I want to set the mode of my FormView based on the values the SelectCommand of my SqlDataSource returns. If a certain field contains Null, I want to have Edit mode, and when the field has a value, I want to have ReadOnly.

Apparently I cannot use databinding to set the DefaultMode, so I guess I have to attach code to SqlDataSource1_Selected? But I don't really know how to read out the field values in this way...

Thanks, Peter
 
You will have to use something other than a sqldatasource for this. You can use a sqldataadapter, or command object to fill a datatable. Then from there, check the value and set the mode accordingly.
 
I found it, I needed to use FormView.DataItem["label"] to access the fields...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top