Showing posts with label programmatically. Show all posts
Showing posts with label programmatically. Show all posts

Friday, February 24, 2012

Inserting records using the details view or programmatically

I'm a new user to vwd.

If I use a details view control on my page, I have noticed that the "New" link is not visible unless there is at least one record in the table. Is there any way of making it visible where there aren't any records?

My web pages are currently hosted at vwdhosting. I have uploaded my database with the record structure onto the web site and I am using a remote connection string to access it. I have had users updating data in another table on the remote database. If I add records to my new table locally and upload the database to the remote site, all the data that my users have been adding will be lost.

So, if I can't add my first record using a control on my web page when there are no records in the table, should I be doing it programmatically? If so, how?

Thanks,

Julie

Use the empty template. Add a button, that has a commandname of "New".

I usually use something like:

No records found, <asp:button ...>Add a new record</asp:button>

as the empty template.

|||Fabulous, thank you.

Sunday, February 19, 2012

Inserting NULL into Datetime field

I have a datetime field in a database which I am programmatically inserting values into. The field can be null or not null. However, I am having problems inserting NULL as part of my SQLCommand.

The value is pulled from a text box (linked to a calendar extender) and when I select a value it is being inserted fine. If I just leave the box blank though, I want the field to be set to NULL. I have tried adding in ,DBNULL.Value, as part of my VALUES(…) string, but this throws an exception. I Have tried just inserting '' but that also throws an exception ("The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value"), so I don't know how I can insert this value when the field is blank?

Can anyone shed some light please?

Thanks

Check to see if the last answer of this other post helps:http://forums.asp.net/t/996855.aspx

|||

You can also check if this post helps:http://dotnetjunkies.com/WebLog/dinakar/articles/74221.aspx