score:2
Accepted answer
you can use following conditional operator:
txt_objective.text = dtreqmas.rows[0].isnull("objective")
? string.empty : dtreqmas.rows[0].field<string>("objective");
score:0
try this
txt_objective.text = (dtreqmas!=null && dtreqmas.rows.count>0 && !string.isnullorempty(dtreqmas.rows[0]["objective"])?dtreqmas.rows[0]["objective"].tostring():string.empty;
score:1
i think, this may helpful for you:
txt_objective.text = (string.isnullorempty(dtreqmas.rows[0]
["objective"].tostring()) ? string.empty : dtreqmas.rows[0]
["objective"].tostring().trim());
score:7
this should work:
txt_objective.text = (dtreqmas.rows[0]["objective"] ?? string.empty).tostring().trim();
Source: stackoverflow.com
Related Query
- How to check string for null and assign its value in the same line
- Linq query, how to check for a null value and use the value 0 in place of a null?
- How to check the property elementAt() has a value and its not null
- Using LINQ how would I check if a XML row contains a field and if it does check a different field on the same row for a value
- How to check if all list items have the same value and return it, or return an “otherValue” if they don’t?
- How to assign empty string if the value is null in linq query?
- c# linq how to check for null values in the same column that i need to be not null
- how to check the value for null in linq?
- How to check for null and empty string in Exression.Constant?
- How can I check null and assign new value in linq anonymous type to select expected sql result
- How to get the index of a string value in a list, and assign it to a field in linq
- Searching each property value of an IQueryable collection of T against the value of a search query. How do I test for NOT NULL and CONTAINS together?
- Linq check for null and replace null value in orderby
- linq sql find duplicates but take null and empty string as the same
- How to unpack an expression tree and check for null values
- In List<string>, how to use the Contains() method and check if value is empty
- How to check for null values before Converting a comma Separated string to Generic List
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- How to check if an item exists in a string List and if it exists, get its index
- How to check for the absence of any value in a list from a set server-side in LINQ? (SQL given)
- Linq check value for equality in collection and assign value to other collection
- How to query in linq and check if the passed value is empty
- check for a substring(of a string) in the dictionary and return the key's(substring) value
- how to check for a value in the last 10 entries using linq to entities
- What is the most efficient way or best practice for null check when you use Split and FirstOrDefault methods together?
- How to write LINQ query for fetching the specific records and generating new result at the same time?
- How to find string in Dictionary list and get its pair integer value
- C# LINQ Generic Extension Method to check if sequence is the same and return it's value
- How do i obtain foreign table field using string value for fieldname with reflection and entity framework
- linq to sql c#: replace a foreign key with its string value and keep the table structure
More Query from same tag
- Combining two LINQ conditionals in where clause
- Using LINQ Query DataTable using partial column names
- LINQ lambda expression, finding a child object where property is == X
- Observable<string> updated events?
- Compare dates and then insert data
- Unexpected results in Linq query always + 1
- How to load XML to List<string>
- Linq Join query 4 tables
- get selected value from combobox with data source is anonymous type
- Using TempData in Linq
- Query and updating a property in a collection using LINQ
- Linq to get elements in a list (parent) where a condition is satisfied on property of an object in a child list?
- trying to convert sql to linq sql
- Linq Method error
- Get Key Name from nested json object
- Linq query for left-join
- with LINQ, how to transfer a List<List<string>> to List<string>?
- Get count of longest list inside a list with LINQ
- C#: how do you check lists are the same size & same elements?
- Paging with LINQ without sorting
- Possible to do this in better than O(n^2) time?
- Tiny database C# library/code to handle multiple columns of data?
- How to cast INT32 to INT during a SQL select through a LINQ data context?
- Linq "equals" keyword
- where clause evaluated by if
- Null check ObservableCollection before querying it
- How to get row count 3 table join and lambda expressions?
- how can i page into my list using linq
- Filter Linq Child Collection by another List/Array
- Fastest way to query data by a specific date and data by next older date from oracle table?