请问能否控制DataGrid编辑时的文本框宽度??

jonsonzxw 2002-03-26 05:47:40
请问能否控制DataGrid编辑时的文本框宽度??
...全文
53 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
raychiu 2002-10-09
  • 打赏
  • 举报
回复
在html里边写入模板列,然后在该模板列上写上width=“你需要宽度的值”例如
<asp:TemplateColumn HeaderText="xxx">
<ItemTemplate>
<asp:LinkButton Text='<%# container.dataitem("数据表字段名") %>' Width=100 Runat=server ID="x" CommandName ="xx"/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox Width=100 ID="friend_id" Text='<%# container.dataitem("数据表字段名") %>' Runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
hobo_boy 2002-08-16
  • 打赏
  • 举报
回复
在codebehind中,直接设文本框的长度
hongfeipb 2002-08-14
  • 打赏
  • 举报
回复
使用itemtemplte中的edit templte的模板,在模版中可以定义任何你想定义的textbox的属性
kokokokokoko 2002-08-10
  • 打赏
  • 举报
回复
你直接設定文本框的寬度不就得了
juqiang 2002-04-20
  • 打赏
  • 举报
回复
哈哈,昨天问了Icyer,然后又问了微软的专家,设置Style.Wrap=false可以解决每个行高度不同的问题。
bxl2000 2002-04-17
  • 打赏
  • 举报
回复
可以。你可以看看DataGrid里面的属性。单元格内的边框距离应该就是啊。
Cellpadding设为某个值就可以了。
icyer 2002-03-27
  • 打赏
  • 举报
回复
try it.

在DataGrid的ItemCreated事件中加入如下代码:
if (e.Item.ItemType == ItemType.Edit)
{
int i;
for (i=0; i<DataGrid1.Columns.Count; i++)
{
TextBox txt = e.Item.Cell[i].Controls[0];
if (txt != null)
txt.Width = Unit.Pixel(100); //设为100px
}
}

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧