一个关于DATAGRID编辑的问题(自动生成TEXTOX,控制长度的问题),急!!!前台:
<asp:BoundColumn HeaderText="合同岗位" DataField="Htgw" ItemStyle-HorizontalAlign="Center" />后台:
放在Grid_Update事件中:
CType(e.Item.Cells(6).Controls(0), TextBox).Width = Unit.Pixel(150)
老是不能定义自动生成文本框的长度,谁帮我解决一下啥?
<asp:BoundColumn HeaderText="合同岗位" DataField="Htgw" ItemStyle-HorizontalAlign="Center" />后台:
放在Grid_Update事件中:
CType(e.Item.Cells(6).Controls(0), TextBox).Width = Unit.Pixel(150)
老是不能定义自动生成文本框的长度,谁帮我解决一下啥?
{
if( e.Item.ItemType == ListItemType.EditItem )
{
TextBox TB = ( TextBox )e.Item.Cells[6].Controls[0];
TB.Width = 77;
}
}
Sub MyGrid_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='lavender'") If e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='ghostwhite'") 'Dim i As Integer
'For i = 0 To e.Item.Cells.Count - 1 Step i + 1
'Dim txt As TextBox = CType(e.Item.Cells(i).Controls(0), TextBox)
'txt.Width = Unit.Pixel(50)
'Next 'Dim txtDate_ZzText As TextBox = CType(e.Item.Cells(4).Controls(0), TextBox)
'txtDate_ZzText.Width = Unit.Pixel(50)
'txtDate_ZzText.Width = MyGrid.HeaderStyle.Width
Else
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='ghostwhite'")
End If '删除确认弹出“确定”与“取消”对话框
Dim btnDelete As LinkButton = CType(e.Item.Cells(10).Controls(0), LinkButton)
btnDelete.Attributes.Add("onclick", "javascript:return confirm('确定删除吗?删除以后将无法恢复!');") End If
'删除确认弹出“确定”与“取消”对话框
Dim btnDelete As LinkButton = CType(e.Item.Cells(10).Controls(0), LinkButton)
btnDelete.Attributes.Add("onclick", "javascript:return confirm('确定删除吗?删除以后将无法恢复!');")
这个没有问题,郁闷!