I have a sql database that on some field will have a empty string/field. I am using a Datalist to display my results. How do I not make the labels that are empty not display? Currently if the field is empty it will leave a space there which my goal is if the field is empty do not leave a white space instead move the other colunms up.
I have setup my business object to have a create_date and edit_date members both datetime datatypes. My company want to display the create_date and edit_date fields in a gridview for each transaction. The problem i have is that after insterting a record it will have a valid create_date but no edit_date and when displayed in the gridview it defaults to datetime.minvalue (My default). How on earth do i show an empty field in my gridview for a null datetime field in the database?
I am using similar architecture to the Imar Spaanjaars example of a tiered solution. With a few small tweeks it has worked well for me for ages. I am passing a List<Database> to my object datasource which connects to my gridview.
I have a web form and I have a user control on it. This user control contains a panel with some user properties that are to be stored in a database. So far nothing fancy. The user control itself contains a panel and is working fine (all code to retrieve and store the values is working).
I used the default settings of creating a user control and one of them was AutoEventWireup=true. This works fine because I also have some dropdown boxes (and other fields) that need to be filled with values from the database and that happens in the Page_load event.
The panel specifies the 'DefaultButton' which calls a method when clicked to save the values after the user has changed them.
On this click the code of the method is called, I confirmed that, but I found out that the values of my controls on the user control (for example the Textbox control) are empty. As a non-ASP.NET developer I couldn't figure out why. So I changed some settings like AutoEventWireup to false.
Off course this resulted in my dropdown boxes no longer to be initially filled, but my surprise was big to find out my controls actually contained the values the user typed in.
Logically I need both the values and the dropdowns filled, but for now it seems one or the other.
I have a simple WCF service that returns the time from the server. I've confirmed that data is being sent by checking with Fiddler. Here's the result object xml that my service sends according to fiddler.
Literally the only difference is the namespaces within the application. But still the values being returned are null, empty or a .NET default.
If I have JSON like this and pass it to the engine I am using to create a PDF file, the word "null" appears on the PDF. This isn't really my example, but I googled "json replace null empty string" and this was a hit, which is a good representation of my data, also:
We use a rendering engine that creates a PDF from a fixed template and variable data in the form of a json string. But our customers don't want to read that the id is "null", they want to read that the id is blank. In my C# program, the json is just a string, so I can easily do something like this:
jsonString = jsonString.Replace("null,", ",");but the issue is I can't replace null-comma with a comma, because then it's invalid json.
how to I make the rendering engine *and* my customer both happy?
here is my code for selectiong some records from db table
string strSql = "select * from mtblNBD where SentTo=@SentTo and InternalStatus Is NULL order by DeadLine desc"; SqlCommand com = new SqlCommand(strSql, con); com.Parameters.Add("@SentTo", SqlDbType.NVarChar, 50).Value = (string)Session["uname"];
here I am using parameters for SenTo field but not for NULL so it is ok... or should I use parameters for this field where value is NULL , if yes then how can I use parameter for this
above string i have displayed in front end thrgh response.write i.e by assigning string abc to viewstate. also i am tryin to genetrate above input fields from database , so i have to make it dynamic in a loop. so when a user updates any of those dynamically created fields i need to retreive those values in a loop
something like this :
field1.text , field2.text ......so on till fieldn.text ....i want to assign these values to array
string arr1 = new string[nooffields]; arr1[i] = fieldi.text;
I have a number of nullable DateTime fields (Entity Framework model), and in my MVC view, I want to display custom text when the value is null. I would normally use the C# ? or ?? operators, but these can't be used unless I make all output occur in a response.write. Also, I need to handle existing DataAnnotations (like format string). It's all pointing to a helper method, or an extension method on Html. I am hoping there is a DataAnnotation attribute that I missed that covers this scenario.
Is there a way to use the <%: operator and have custom text for null values?
how to disabled and uncheck the checkbox values from database fields..if i have entry in my database records as :Name Seats DateSumit 1,3 11-Dec-2010Sanjeev 2,4 12-Dec-2010Manish 1,3,4 11-Dec-2010I want on page load event the default date for todays is 11-Dec-2010 then checkbox1, checkbox2, checkbox3, checkbox4 will be disabled and unchecked state for 11-Dec-2010as you see on the above database structure the seats for 11-Dec-2010 is 1,2,3,4 so the chekbox1, checkbox2, checkbox3, checkbox4 will be disabled..
my table field allows null values. but my code below does not work unless a value is assigned to my variable even though the glable variable is initialised to 0; tried the DBNull.Value - still, it gives me error as the table in question is linked and expecting a value.