Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2007, 04:30 PM
vsr vsr is offline
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default datagrid, innertext, javascript, database update

Hi
I have a .aspx page that contains some javascript so that
when a user presses a checkbox another cell in the datagrid is filled with the current date . That works fine

My probelm.... when I have the user press the update button (which does a
post back that loops through the datagrid and updates a database) the
field/cell that is filled by the javascript appears to be blank in my update
code, even though I can see it on the screen.
This is very urgent. Any help is appreciated.


 <script type="text/javascript">
function getCurrentDateTime(chk, chkId)
{
var checkbox = chk
var lstIndx = chkId.lastIndexOf('chkComplete')
var spanId = chkId.substr(0,lstIndx) + 'lblDate';
var spanText = document.getElementById(spanId);

if (checkbox.checked == true)
{
var currentDate = new Date()
var crDT = currentDate.getDate()+ "/" + currentDate.getMonth() + "/" + currentDate.getFullYear() ;
spanText.innerText=crDT;
spanText.innerHTML=crDT;

}
else
{
spanText.innerHTML='';
}
}
</script>

My datagrid is as follows:


<asp:DataGrid ID="dgCycleCheckList" runat="server" Visible="true" AutoGenerateColumns="false" DataKeyField="Cycle_Checklist_id_pk">
<Columns>
<asp:TemplateColumn HeaderText="Completed" HeaderStyle-
HorizontalAlign="Center">
<ItemTemplate>
<input type="checkbox" id="chkComplete" runat="server"
checked='<%# DataBinder.Eval(Container.DataItem, "Completed") %>'
onclick ="getCurrentDateTime(this,this.id)" />
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Date Completed"
HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "DateCompleted") %
>'></asp:Label
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Cycle_Checklist_id_pk" Visible="false" HeaderStyle-HorizontalAlign="Center"></asp:BoundColumn>
</Columns>
</asp:DataGrid>


 
Old November 6th, 2007, 05:54 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

So does it work if you hand type a date into the date field within the datagrid? Can you see the value go into the SQL statement when you debug?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Access Database with datagrid jeff_M General .NET 2 May 19th, 2007 10:44 AM
update DataBase from DataGrid AnwarSadique C# 1 July 26th, 2006 09:03 AM
Problem with update database in datagrid annie_stwg ASP.NET 1.0 and 1.1 Basics 4 April 1st, 2006 12:10 AM
problem in getting innerText of iframe BurhanKhan Javascript 6 August 24th, 2004 10:55 AM
Datagrid update, dropdownlist database insertion herman ASP.NET 1.0 and 1.1 Professional 2 October 11th, 2003 01:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.