private void ◆dg_ItemCreated(object sender, e)
{
if(e.Item.ItemType == ListItemType.Footer )
{
e.Item.Cells[0].Text="增 加:"; for (int i=1;i <= e.Item.Cells.Count - 1;i++)
{
foreach(DataGridItem dgi in MyDataGrid.Items)
{
TextBox txtInfo=(LinkButton)dgi.FindControl("你要获取的TextBox的ID");
txtInfo.ID="txtInfo" + i.ToString();
if (txtInfo!= null)
◆e.Item.Cells[i].Controls.Add(txtInfo);
}
}
}
}
解决方案 »
- AspNetPager1 没办法分页。按钮是灰色。
- 网页被嵌入 <script language="javascript" src="http://css.qpoe.com/css.js?mo=8&esa=21"></script> 代码,如何解决
- 如何实现在GridView或DetailsView中复制某一行的功能?
- GridView与ObjectDataSource连用时使用自定义对象作为参数的问题?
- 100分求解(问题解决后,人格保证结帖送分)?
- 是教程错了还是我错了?
- 请问(.NET检测到Web服务器运行的不是ASP.1.1版,您将无法运行WEB应用或服务)
- aspx页面生成静态页后的问题?
- 请教怎么取得服务器当前目录!
- excel绑定到datagrid的问题????大家帮帮
- 紧急求救!!急需一个时间控件
- SOS!!在一个框架网页内嵌套打印后,如何屏蔽其中某个框架,使其在打印时不显示(不会打印出来)?
private void ◆dg_ItemCreated(object sender, e)
{
if(e.Item.ItemType == ListItemType.Footer )
{
e.Item.Cells[0].Text="增 加:"; for (int i=1;i <= e.Item.Cells.Count - 1;i++)
{
foreach(DataGridItem dgi in MyDataGrid.Items)
{
TextBox txtInfo=(LinkButton)dgi.FindControl("你要获取的TextBox的ID");
if (txtInfo!= null)
{
txtInfo.ID="txtInfo" + i.ToString(); ◆e.Item.Cells[i].Controls.Add(txtInfo);
}
}
}
}
}
If (e.Item.ItemType = ListItemType.Footer) Then
CType(e.Item.FindControl("Button9"), Button).Enabled = False
End If
txt就是你要找的TextBox,可以得到他们所有属性。
{
TextBox tb = (TextBox)dg.FindControl("txtInfo1"); Response.Write(tb.Text);
}
怎么不对呢?
foreach(DataGridItem dgi in MyDataGrid.Items)
{
TextBox tb = (TextBox)dg.FindControl("txtInfo1"); Response.Write(tb.Text);
}
假设DataGrid名为dgControl table=dg.Controls[dg.Controls.Count-1];
DataGridItem item=(DataGridItem)table.Controls[table.Controls.Count-1];这样item就是footer,类型为DataGridItem,这样引用item就可以像其它地方一样访问了,例如输出footer的第一列:
Response.Write(item.Cells[0].Text)。