默认的TextBox太宽了,我用下面的程序改变其宽度不知道是哪里写错了,小弟我刚接触ASP.NET,麻烦大家多多指教 .分虽然少点但是希望大家不要嫌弃.
void UserList_EditCommand(object sender, DataGridCommandEventArgs e) {
UserList.EditItemIndex=e.Item.ItemIndex;
LoadGrid();
TextBox curText;
for(int i=0;i<UserList.Columns.Count;i++)
{
if(UserList.Items[e.Item.ItemIndex].Cells[i].Controls[0].GetType().ToString()=="System.Web.UI.WebControls.TextBox")
{
curText=(TextBox)UserList.Items[e.Item.ItemIndex].Cells[i].Controls[0];
curText.Width=100;
}
}
}
错误信息如下:
Specified argument was out of the range of valid values. Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
Source Error:
Line 82: {
Line 83:
Line 84: if(UserList.Items[e.Item.ItemIndex].Cells[i].Controls[0].GetType().ToString()=="System.Web.UI.WebControls.TextBox")
Line 85: {
Line 86: curText=(TextBox)UserList.Items[e.Item.ItemIndex].Cells[i].Controls[0];
Source File: F:\IIS\design\usermanage.aspx Line: 84
void UserList_EditCommand(object sender, DataGridCommandEventArgs e) {
UserList.EditItemIndex=e.Item.ItemIndex;
LoadGrid();
TextBox curText;
for(int i=0;i<UserList.Columns.Count;i++)
{
if(UserList.Items[e.Item.ItemIndex].Cells[i].Controls[0].GetType().ToString()=="System.Web.UI.WebControls.TextBox")
{
curText=(TextBox)UserList.Items[e.Item.ItemIndex].Cells[i].Controls[0];
curText.Width=100;
}
}
}
错误信息如下:
Specified argument was out of the range of valid values. Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
Source Error:
Line 82: {
Line 83:
Line 84: if(UserList.Items[e.Item.ItemIndex].Cells[i].Controls[0].GetType().ToString()=="System.Web.UI.WebControls.TextBox")
Line 85: {
Line 86: curText=(TextBox)UserList.Items[e.Item.ItemIndex].Cells[i].Controls[0];
Source File: F:\IIS\design\usermanage.aspx Line: 84
解决方案 »
- MVC3(Razor)循环中使用document.write
- 【算法比赛】看谁分的最快
- 大文件上传组件问题(SlickUpload),急,高手请进,马上给分
- 我的文件上传控件里为什么找不到控制文件类型的accept属性啊?
- 有没有大连的兄弟姐妹,留一下联系方式,互相交流学习,顺便发点分!!
- 请教一下,TOOLBARTEXTBOX的点击事件怎么弄?再现等待!
- 在ASP.NET中,有SMTP服务发邮件如何发到DOMINO的lotus邮箱中
- 救命,在Asp.net调用Excel以后,不能回收资源
- 如何判断DataGrid1.SelectedItem.Cells[1]被实例化??急!!!!!!!
- [求思路]如何在网页中判断订单是否安全的支付成功
- 关于datagrid/datalist中做更新功能.....
- aspnet_wp.exe进程问题
DataGrid1.Columns(0).ItemStyle.Width.Pixel(100)
DataGrid1.Columns(1).ItemStyle.Width.Pixel(100)
我是把它們放在datagrid1.databind()之後
你只用修正你編輯那一行即可,而不必要迴圈
即只修正e.item.ItemIndex這一行即可