Chevy Mark Sunderland

Chevy Mark Sunderland

  • NA
  • 188
  • 167.3k

Calendar problem

Mar 29 2012 11:28 AM
Hi there, I hope your appreciated help.
First of all I must say that I am a newbie when it comes to net language.

This is the GridView.

The problem is not change date value in the TextBox id="EditData" if I selected the new date in the calendar.

Why? can you help me?
Thanks in advance.

<script runat="server">
public void Page_Load (Object sender, EventArgs e)
{
OdbcConnection myConnectionString =
new OdbcConnection(
ConfigurationManager.ConnectionStrings["ConnMySQL"].ConnectionString);
myConnectionString.Open();

myConnectionString.Close();
myConnectionString.Dispose();
}

protected void calDate_SelectionChanged(object sender, EventArgs e)
{

TextBox  EditmyDates  = (TextBox)GridView1.Rows[GridView1.EditIndex].FindControl(" EditmyDates");


}

</script>

<script type="text/javascript">
function popupCalendar() {
var dateField = document.getElementById('dateField');
if (dateField.style.display == 'none')
dateField.style.display = 'block';
else
dateField.style.display = 'none';
}
</script>

<form id="form1" runat="server">
<div id="dateField" style="display:none;">
<asp:Calendar id="calDate" OnSelectionChanged="calDate_SelectionChanged" Runat="server" />
</div>
<div>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnMySQL %>"
ProviderName="<%$ ConnectionStrings:ConnMySQL.ProviderName %>"
SelectCommand="SELECT myDates FROM tbl_copy
ORDER BY myDates DESC"
UpdateCommand="UPDATE tbl_copy
SET myDates=? WHERE ID=?">
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" Direction="Input" />
<asp:Parameter Name="myDates" Type="DateTime" Direction="Input" />
</UpdateParameters>
</asp:SqlDataSource>

........


<asp:TemplateField HeaderText="myDates" SortExpression="myDates">
<ItemTemplate>
<asp:Label ID="Label1" Text='<%# Bind("myDates", "{0:dd/MM/yyyy}") %>' Runat="Server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="EditmyDates" Runat="Server"
DataSourceID="SqlDataSource1"
DataTextField="myDates"
DataValueField="myDates"
Text='<%# Bind("myDates","{0:dd/MM/yyyy}") %>'
Font-Size="8pt" Width="70" />
<img src="/images/CALEN.GIF" onclick="popupCalendar()" />
</EditItemTemplate>
</asp:TemplateField>

...

</div>
</form>