IT Community - Software Programming, Web Development and Technical Support

ASP.NET Data Controls

This is a discussion on ASP.NET Data Controls within the ASP and ASP.NET Programming forums, part of the Web Development category; hi guys, I am using Visual Studio 2005 and ASP.NET 2.0 and SQL Server Express 2005 Ok I'...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #121 (permalink)  
Old 09-25-2007, 07:52 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi guys,

I am using Visual Studio 2005 and ASP.NET 2.0 and SQL Server Express 2005
Ok I've come up with the next problem:

I want to check if a field has a value and if it has it should display it, otherwise it shoudn't. Now In my database I've got fields wich have the Nulls allowed properties.These fields will have the initial value of NULL and when I erase the NULL value it will have no value.
So Im using the next statements to check this:

<%#IIf(IsDBNull(DataBinder.Eval(Container.DataItem , "Adreslijn2")) , "" , DataBinder.Eval(Container.DataItem, "Adreslijn2") & "<BR />")%>
This will work if the field has the initial NULL value but if it has no value or a value, both ways it will give no error but it will still print the breakline even if it has an empty value because it is not NULL ofcourse while it also shouldn't print the breakline if it has an empty value.

<%#IIf(DataBinder.Eval(Container.DataItem, "Adreslijn2") = ""), "" , DataBinder.Eval(Container.DataItem, "Adreslijn2") & "<BR />")%>
This will work if the field has no value (so when I have erased the initial NULL value) but when the field still has the initial NULL value it will give the following error:
Operator '=' is not defined for type 'DBNull' and string "".
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Operator '=' is not defined for type 'DBNull' and string "".
Using OR in the IIF line of course also does not work because it will still give the error when the field contains the NULL value
Does anyone here know a solution for this? Is it maybe possible to give my fields in my database an initial empty value instead of NULL so when a new record is created it will fill the empty records with no value instead of NULL or is there another solution to this?


Thanks in advance
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #122 (permalink)  
Old 09-25-2007, 08:03 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

Hi venkat,

Try using
<%#IIf(String.IsNullOrEmpty(DataBinder.Eval(Contai ner.DataItem, "Adreslijn2")) , "" , DataBinder.Eval(Container.DataItem, "Adreslijn2") & "<BR />")%>
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #123 (permalink)  
Old 09-25-2007, 08:04 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi H2o,

Thanks for trying to help but I've tried it and it doesn't work when the value of the field is NULL
I get this error:
Conversion from type 'DBNull' to type 'String' is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.
I think I should have to construct something like IF (thedataitem is DBNull) THEN do action ELSE IF (the dataitem is empty) THEN do action ELSE do other action... but I have no idea how to do that inside a repeater using IIF...
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #124 (permalink)  
Old 09-26-2007, 06:56 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi,

OK... try this...
<%#IIf(IsDBNull(DataBinder.Eval(Container.DataItem , "Adreslijn2")) OrElse String.IsNullOrEmpty(DataBinder.Eval(Container.Dat aItem, "Adreslijn2")) , "" , DataBinder.Eval(Container.DataItem, "Adreslijn2") & "<BR />")%>
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #125 (permalink)  
Old 09-26-2007, 07:14 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi,

That's it! Works like new

Thanks alot
__________________
Venkat
knowledge is Power
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #126 (permalink)  
Old 09-26-2007, 07:21 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 246
H2o is on a distinguished road
Thumbs up Re: ASP.NET Data Controls

hi,

No worries!!
I think you might be getting confused here!! There aren't any "IIF functions" as you describe them.
IIF is a function which compacts a normal
IF condition THEN
condition_is_true_value
ELSE
condition_is_false_value
END IF
into 1 line... so really it's about understanding how the 3 component parts work... and getting your logic right!!
So in your case with IIf(condition, true_value, false_value) you're comfortable with the true_value and false_value, but not building the condition itself.
Well the condition can be any VB you want... in this case you could've written your own function that checks to see if the value is DBNull or String.Empty and then returns a Boolean... and then called that.
Instead I put the logic inline for you with judicious use of OrElse... this is something that is very important to understand...
statement1 And statement2 - this means that both statement1 and statement2 will be evaluated and both must be true
statement1 Or statement2 - this means that both statement1 and statement2 will be evaluated and either one must be true
statement1 AndAlso statement2 - this means that both statement1 and statement2 must be true, but if statement1 is false statement2 is not evaluated
statement1 And statement2 - this means that either statement1 or statement2 must be true, but if statement1 is true statement2 is not evaluated
Hope this all makes sense!
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #127 (permalink)  
Old 11-07-2007, 02:04 AM
sathian sathian is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 252
sathian is on a distinguished road
Default Re: ASP.NET Data Controls

I have one doubt....can we use the same
DataBinder.Eval Method for HTML controls with runnat="server"
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #128 (permalink)  
Old 11-26-2007, 01:37 AM
rsarrr rsarrr is offline
D-Web Trainee
 
Join Date: Nov 2007
Posts: 1
rsarrr is on a distinguished road
Default Re: Implementation Data Controls in asp.net

Are you defining the name of your checkbox explicitly? It is not enough to The Repeater control renders a read-only list from a set of records returned from a data source. Like the FormView control, the Repeater control does not
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #129 (permalink)  
Old 12-26-2007, 04:12 AM
arjkhanna arjkhanna is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 1,015
arjkhanna is on a distinguished road
Default Re: ASP.NET Data Controls

what are the differences between property and local variable in

C#???

The Local variable defined inside the class adds up to the state

definition of the object during runtime, So when I say any object is in

valid state I necessarily mean that every member/local field of the class

has it's value in the desired and appropriate state. A property is the

interface provided for the outside world to access any particular field of

the class to manipulate the object state in the controlled way.

That's why it's the standard practice to encapsulate the public fields

through the properties. The properties can control the access to internal

fields through the get and set functions, you can choose to implement any

one or both the functions in order to control the access based on the

requirement.

Apart from the controlled access and security the properties also offer

another major advantage over the public field like, say if any exception is

raised when setting any particular field the field may be left in the

invalid state, where as if any exception occurs while accessing the field

through the property the old value is retained automatically there by

laving the encapsulated field in the valid state even though the exception

occurs.
__________________
A.Rajesh Khanna
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #130 (permalink)  
Old 04-19-2008, 01:52 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 181
saravanan is on a distinguished road
Default Re: ASP.NET Data Controls

i want more details about gridview control and we can use more than one grid view control in single form
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #131 (permalink)  
Old 04-19-2008, 01:56 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 181
saravanan is on a distinguished road
Default Re: ASP.NET Data Controls

how to do paging in asp .net data controls
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/asp-asp-net-programming/3113-asp-net-data-controls.html
Posted By For Type Date
ASP.NET Data Controls - Page 2 - DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 08-27-2007 12:10 AM
DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 08-17-2007 02:02 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can we Dynamically create web controls Kirubhananth ASP and ASP.NET Programming 3 03-14-2008 09:00 PM
WebParts controls S.Vinothkumar ASP and ASP.NET Programming 5 11-16-2007 02:06 AM
How to add controls into the page dynamicaly kingmaker ASP and ASP.NET Programming 1 07-23-2007 06:39 AM
Asp.net controls not supported by Ajax? Gopisoft ASP and ASP.NET Programming 0 07-16-2007 11:22 PM
MFC Updates for Vista Common Controls Karpagarajan C and C++ Programming 0 03-29-2007 01:32 PM


All times are GMT -7. The time now is 01:56 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0