Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 07, 2012 08:41 AM by Qin Dian Tang - MSFT
Member
5 Points
16 Posts
May 03, 2012 05:34 PM|LINK
Listview is connected to SqlDataSource. I want to display current date for 'datewebTextBox' when I ask user to insert a new record. How can I do that?
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ScheduleId" DataSourceID="SqlDataSource1" InsertItemPosition="LastItem" OnItemUpdating="Auto_Lookup_Update" OnItemInserting ="Auto_Lookup_Insert" OnInit="Auto_Date_Insert" > <InsertItemTemplate> <tr style=""> <td> <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert"/> <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" /> </td> <td> <asp:TextBox ID="datewebTextBox" runat="server" Text='<%# Bind("dateweb","{0:d}") %>' /> </td> <td> <asp:TextBox ID="timewebTextBox" runat="server" Text='<%# Bind("timeweb") %>' /> </td> <td> <asp:TextBox ID="daywebTextBox" runat="server" Text='<%# Bind("daywebp") %>' /> </td> <td> <asp:TextBox ID="durationTextBox" runat="server" Text='<%# Bind("duration") %>' /> </td> <td> <asp:TextBox ID="recordidTextBox" runat="server" Text='<%# Bind("recordid") %>' /> </td> <td> <asp:TextBox ID="daycrawlTextBox" runat="server" Text='<%# Bind("daycrawl") %>' /> </td> <td> <asp:TextBox ID="timecrawlTextBox" runat="server" Text='<%# Bind("timecrawl") %>' /> </td> <td> <asp:TextBox ID="MainTitlewebTextBox" runat="server" Text='<%# Bind("MainTitleweb") %>' /> </td> <td> <asp:TextBox ID="maintitlecrawlTextBox" runat="server" Text='<%# Bind("maintitlecrawl") %>' /> </td> <td> <asp:TextBox ID="ShortDescriptionTextBox" runat="server" Text='<%# Bind("ShortDescription") %>' /> </td> <td> </td> </tr> </InsertItemTemplate> </asp:ListView>
Contributor
6439 Points
1184 Posts
May 05, 2012 02:36 PM|LINK
Where and when do you want to display the date in the datewebTextBox?
All-Star
113532 Points
12480 Posts
Microsoft
May 07, 2012 08:41 AM|LINK
Hi,
Just set the date to Text property of TextBox:
Text='<%# System.DateTime.Now.ToString("d") %>'
Thanks,
mona agarwal
Member
5 Points
16 Posts
Entering some of ListView textboxes programatically
May 03, 2012 05:34 PM|LINK
Listview is connected to SqlDataSource. I want to display current date for 'datewebTextBox' when I ask user to insert a new record. How can I do that?
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ScheduleId"
DataSourceID="SqlDataSource1" InsertItemPosition="LastItem" OnItemUpdating="Auto_Lookup_Update" OnItemInserting ="Auto_Lookup_Insert" OnInit="Auto_Date_Insert" >
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert"/>
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
<asp:TextBox ID="datewebTextBox" runat="server" Text='<%# Bind("dateweb","{0:d}") %>' />
</td>
<td>
<asp:TextBox ID="timewebTextBox" runat="server" Text='<%# Bind("timeweb") %>' />
</td>
<td>
<asp:TextBox ID="daywebTextBox" runat="server" Text='<%# Bind("daywebp") %>' />
</td>
<td>
<asp:TextBox ID="durationTextBox" runat="server"
Text='<%# Bind("duration") %>' />
</td>
<td>
<asp:TextBox ID="recordidTextBox" runat="server"
Text='<%# Bind("recordid") %>' />
</td>
<td>
<asp:TextBox ID="daycrawlTextBox" runat="server"
Text='<%# Bind("daycrawl") %>' />
</td>
<td>
<asp:TextBox ID="timecrawlTextBox" runat="server"
Text='<%# Bind("timecrawl") %>' />
</td>
<td>
<asp:TextBox ID="MainTitlewebTextBox" runat="server"
Text='<%# Bind("MainTitleweb") %>' />
</td>
<td>
<asp:TextBox ID="maintitlecrawlTextBox" runat="server"
Text='<%# Bind("maintitlecrawl") %>' />
</td>
<td>
<asp:TextBox ID="ShortDescriptionTextBox" runat="server"
Text='<%# Bind("ShortDescription") %>' />
</td>
<td>
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
mm10
Contributor
6439 Points
1184 Posts
Re: Entering some of ListView textboxes programatically
May 05, 2012 02:36 PM|LINK
Where and when do you want to display the date in the datewebTextBox?
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Entering some of ListView textboxes programatically
May 07, 2012 08:41 AM|LINK
Hi,
Just set the date to Text property of TextBox:
Text='<%# System.DateTime.Now.ToString("d") %>'
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework