你可以在SQL語句中用別名呀,或者在DATAGRID上點擊右鍵-屬性產生器-資料行,就可以選擇相應的字段來定義你的標頭,我用的是繁體版不知你看不看得懂
解决方案 »
- OleDbException (0x80004005): 未指定的错误
- 为什么会显示是'PC-12292206\Administrator' 登录失败呢
- ExecuteScalar()返回的如果没有值,那么是用dbnull.value还是null来判断?
- 急:.NET DataList中TextBox onfocus调用后台静态方法
- Eval()的两种使用区别
- 如何定时生成html页面??
- 如何控制datagrid的表头字段单元格的宽度?
- 一个比较简单的问题(对文件的操作)
- 本人有意购买完整网上购物网站程序-----
- 这样的功能如何实现
- 大家谁有treeview右键功能的例子?或者说说实现过程,最好有代码
- 关于全局变量 解决了再加50分
myDataGrid1.columns[i].HeaderText="my headertext"
当执行这行时,出现以下错误索引超出范围。必须为非负值并小于集合大小。参数名:index 为什么???
请各位大虾指教!!!!!!!!!!!!
myDataGrid1.columns[i].HeaderText="my headertext"
中的i是不是从1开始的,起始是0
索引超出范围。必须为非负值并小于集合大小。参数名:index
我试过,会报下面的错误
myDataGrid1.columns[i].HeaderText="my headertext"我的i不管是0还是1、2、3,都报错误
索引超出范围。必须为非负值并小于集合大小。参数名:index
只不过再databind()以前用,以后用不起作用
如果你实现能够确定一共有几列的话,你可以在设计界面里面,先选定myDataGrid1,然后在属性菜单里面选择columns属性,在里面的选择“绑定列”,手动创建你需要的列,并将“自动创建列”选项卡的勾去掉。这样,你就可以使用上面的方法了
myDataGrid1.columns[i].HeaderText="my headertext"
我是过了,可以的。但是现在的问题就是我想在代码中动态的创建myDataGrid1的列,然后对他们进行操作,还是没有搞懂,继续studying……
能不能给出所有的代码,
我不管怎么试都报错呀
{
//绑定数据源表law到dg1
DataTable dtResult = new DataTable ();
StringBuilder sbWhere=new StringBuilder("");
Int32 n32TotalLine=0;
Law usr_law = new Law (); sbWhere.AppendFormat(" lb = {0} ",Int32.Parse (Request.QueryString ["id"]));
dtResult = usr_law.LoadMuti(sbWhere.ToString(),n32PageSize,1,ref n32TotalLine);
dg1.DataSource = dtResult;
dg1.Height = 30;
dg1.Columns [1].HeaderText="my headertext";
dg1.DataBind();
SetPage(1, n32TotalLine);
dtResult = null;
//显示搜索类别名称
CategoryInfo usr_categoryinfo = new CategoryInfo ();
Category usr_category = new Category ();
usr_categoryinfo.Categoryid = Int32.Parse (Request.QueryString ["id"]);
usr_category.Load (usr_categoryinfo);
lblsearchname.Text = "当前搜索为:"+usr_categoryinfo.Categoryname ;
usr_categoryinfo = null;
usr_category = null;
}
在Itemdatabound事件中
if(e.Item.ItemType == ListItemType.Header)
{
e.Item.Cells[5].Font.Bold=true;
e.Item.Cells[5].Width=200;
e.Item.Cells[5].Text="yyy200";
}
dg2.DataSource = dtResult;
dg2.DataBind ();
Dim strsele1 As String = "select id as 编号, name as 名称,style as 规格,sour as 厂家,monery as 价格 from datasour where " & datasour & "='" & datavalue & "'"
adocmd = New OleDbDataAdapter(strsele1, datasou)
adocmd.Fill(ds, "datasour")