- 爱易网页
-
ASP.NET教程
- 急在点击日期控件后不能展示在datagrid的textbox中
日期:2014-05-18 浏览次数:20453 次
急!!!在点击日期控件后不能显示在datagrid的textbox中?
点击日期控件后不能显示在datagrid的textbox中,但是如果不是datagrid中的textbox就可以.
代码如下:
.aspx
<script type= "text/javascript " language= "JavaScript ">
var popup0=0;
//打开时间选择窗口
function popupCalendar(url) {
var windowprops = "directorys=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width=190,height=140 " + ",left= " + window.event.x + ",top= " + window.event.y;
popup0 = window.open(url, "x ",windowprops);
} </script>
<asp:datagrid id= "DataGridTeacher " ShowHeader = "false " OnItemDataBound= "DataGridTeacher_ItemDataBound " runat= "server " >
<ItemStyle CssClass= "dgItem "> </ItemStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id= "chkRights " runat= "server "> </asp:CheckBox>
</ItemTemplate>
<ItemStyle Width= "5% " />
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label ID= "lblStudent " runat= "server " Text= ' <%# DataBinder.Eval(Container.DataItem, "XM ") %> '> </asp:Label>
</ItemTemplate>
<ItemStyle Width= "10% " />
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:TextBox ID= "txtValuateDate " CssClass= "textbox " runat= "server "> </asp:TextBox>
</ItemTemplate>
<ItemStyle Width= "10% " />
</asp:TemplateColumn>
......
后台.cs
protected void DataGridTeacher_ItemDataBound(object sender, DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if (itemType == ListItemType.Item || itemType == ListItemType.AlternatingItem)
{
TextBox tb = (TextBox)(e.Item.Cells[2].Controls[1]);
e.Item.Cells[2].Attributes.Add( "style ", "WIDTH: 10%; CURSOR: hand ");
e.Item.Cells[2].Attributes.Add( "onclick ", "popupCalendar( '../../Common/Calendar.asp?form=form1&field=tb '); ");
}
}
估计问题可能出在 field=tb 上,可是又不知如何做
------解决方案--------------------
一般的日期控件都可以把要显示日期的控件ID或对象当参数传进去