Monday, March 12, 2012

how to Copy Item one Gridview to another gridview

I have Two gridview left side where i populate data from Database and other will be empty at 1st time my requirement is when click any item and click to add button it will remove from that cell and add in to second gridview

same thing happens through drag and drop system Drag from one gridview to another well but it will be helpfull how to remove and add one gridview to another can someone give me idea

bye take care
regards
vikrant

Check out these links

http://forums.asp.net/p/1169459/1955946.aspx

http://www.codeproject.com/KB/HTML/SelectMoveRowsFromTables.aspx

Labels: , , , , , , , , , ,

How to convert empty string to Null of Datetime data type

Hi,
This is very annoying to me.
I have a datatable which has two fields of DateTime data type. Both of them are nullable. When I do the update to that datatable, in some cases, Null values are going be put through TextBox and DropDownList's selected Item. But the updated value in database is 01/01/1900 and 12:00 AM which is not the real null value, can anyone help me with this?
My update code:

Dim inputDateAsNewDate
Dim inputSessionAsNewDate

If Trim(txtDate.Text) <> ""Then
inputDate = Convert.ToDateTime(txtDate.Text)
Else
inputDate = System.Data.SqlTypes.SqlDateTime.Null -->01/01/1900
EndIf

If ddlSession.SelectedItem.Text <> ""Then
inputSession = Convert.ToDateTime(ddlSession.SelectedItem.Text)
Else
inputSession = System.Data.SqlTypes.SqlDateTime.Null -->12:00 AM
EndIf

UpdateDT(AgendaItemID, inputDate, inputSession)

Just out of interest, why aren't inputSession and input of type Date System.Data.SqlTypes.SqlDateTime?
If you use the standard CLR DateTime structure, it will also run back to its default value as that's all it can hold.
Make the variables of the appropriate type and then convert the input into SqlDateTime, not the other way around, and your problem should go away.

Labels: , , , , , , , , , , , ,