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.
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='';
}
}
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:BoundColumn DataField="DateCompleted" HeaderText="Date Completed" ReadOnly="true" HeaderStyle-HorizontalAlign="Center"></asp:BoundColumn>
<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>
</Columns>
</asp:DataGrid>