如何将数据库数据绑定到屏蔽的编辑扩展器texbox? [英] How to bind db data to masked edit extender texbox?
问题描述
大家好,
我正在使用带有sql server 2005数据库的基于Web的应用程序,它包含一页用于分支计时的页面.在这2个文本框中可以输入``intime''和``outtime''.成为时间格式被屏蔽的编辑扩展器和Masked编辑验证器与以下文本框一起使用..
Hi all,
I am working with a web based application with sql server 2005 database.It contain one page for branch timing.In this 2 text boxes are there to enter ''intime'' and ''outtime''.To become time format masked edit extender and Masked edit validator is used with text boxes as below..
<asp:TextBox ID="txt_MinTime" runat="server" CssClass="TextBox_Normal"
Width="120px">
<cc1:MaskedEditExtender ID="MaskedEditExtender6" runat="server" Mask="99:99" MaskType="Time" AcceptAMPM="true"
MessageValidatorTip="true" TargetControlID="txt_MinTime">
<cc1:MaskedEditValidator ID="mv1" runat="server" ControlExtender="MaskedEditExtender6" ControlToValidate="txt_MinTime"
EmptyValueMessage="Time is required" InvalidValueMessage="Valid In Time" IsValidEmpty="true" TooltipMessage="Input a time">
现在文本框的外观是这样07:00 PM.
07:00 PM将以十进制19.00的形式保存在数据库中.插入成功.
我也想编辑分支时间,以便将时间更改为AM Pm格式.在检索时间中,所有控件均填充有对应的数据.带有被屏蔽的editvalidator/extender的文本框未填充任何数据.空.
我该如何解决此问题?如果可以,请帮助我....
关于
shamsi
now the textbox appearance is like this 07:00 PM.
The 07:00 PM will be saved in the database as 19.00 in decimal.The insertion is success.
I am also want to edit the Branch time.So that i changed the time to AM Pm format .During the retrieve time all controls are filled with corresponding data.The text box with masked editvalidator/extender are not filled with any data.It is empty.
How can i fix this problem?If you can please help me....
with regards
shamsi
推荐答案
decimal intime = Convert.ToDecimal(dr ["intime"]);
if(intime> 12)
{
txt_MinTime.Text =(intime-12).ToString()+"PM";
}
其他
{
txt_MinTime.Text = intime.ToString()+"AM";
}
decimal intime=Convert.ToDecimal(dr["intime"]);
if(intime>12)
{
txt_MinTime.Text=(intime-12).ToString()+"PM";
}
else
{
txt_MinTime.Text=intime.ToString()+"AM";
}
这篇关于如何将数据库数据绑定到屏蔽的编辑扩展器texbox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!