Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid, Sql Server, Null Values

Status
Not open for further replies.

Compkitty

Programmer
Jan 7, 2005
121
US
When I have null values in my SqlTable, they pull through the system w/ values.
Ie. dates will be 1/1/1900
currency will be $0.00

I need to not let this happen.. how do I do that.. THANKS
 
they pull through the system w/ values
What do you mean by that? Can you explain further?

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Ok in the tables they are <null>, but when either the datagrid is updated/insert/delete or even just loaded these values are there...

Date = 1/1/1900
Currency = $0.00
 
I'm assuming it is because the column types are set to the relevant type (i.e. Date). Can you post your HTML for your DataGrid just to confirm it?

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
HEre's a column from it...


Code:
		<asp:TemplateColumn SortExpression="InternalDueDate" HeaderText="Due Date">
							<ItemStyle Width="75px"></ItemStyle>
							<ItemTemplate>
								<asp:TextBox id=txtDueDate runat="server" Width="90px" Text='<%# DataBinder.Eval(Container, "DataItem.InternalDueDate", "{0:d}").tostring %>'>
								</asp:TextBox>
							</ItemTemplate>
						</asp:TemplateColumn>
Hope this helps.. I do have them set to {o:d} for short date, but the params are varchar (10)..
 
I was able to fix the issue.. here is what I did

Code:
If Out Is System.DBNull.Value.ToString Then
                DaUpdate.UpdateCommand.Parameters("@Date1").Value = DBNull.Value
            Else
                DaUpdate.UpdateCommand.Parameters("@Date1").Value = RptOut
            End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top