因为要把按钮放在一行内容中,而不是单独成一列,所以不能使用模版。
请问有什么办法?
请问有什么办法?
解决方案 »
- dnn user login register 界面 如何汉化
- 上传文件是报未找到路径的一部分,请教
- oledb连接EXCEL 样式问题
- fileupload上传图片时候,整个网站都处于延迟状态~请问怎么解决!
- 提问 散分 又
- 请高手帮忙解决自己写的模板引擎的区块替换C#(代码很少)
- 刚从winform转webform,问个基本的问题,关于用户控件传值的,谢谢~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 救命呀!!!!!!!!!!!!!各位高人
- 一个Calendar的小问题
- 如何使用dataview的rowfilter来进行一个以上条件的筛选
- 帮我看看这个 Sub Button1_Click 该怎么写呀??
- 帮帮忙!!DataGrid中的修改按钮点击之后数据库里的数据没改变?
在ItemCreated事件内 放
<%@ Import NameSpace="System.Data"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="gb2312" />
<meta content="all" name="robots" />
<meta name="Author" content="[email protected] ,活靶子" />
<meta name="Copyright" content="www.AspxBoy.Com,自由版权,任意转载." />
<meta name="Description" content="www.AspxBoy.Com" />
<meta name="Keywords" content="www.AspxBoy.Com,活靶子,huobazi" />
<title> New New Document</title>
<script language="c#" runat="server">protected void Item_Created(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
if( e.Item.ItemIndex == 1 )//第2行
{
TextBox box = new TextBox();
box.ID="myTextBox";
box.Text = e.Item.ItemIndex.ToString();
e.Item.Cells[0].Controls.Add(box);
}
}
}
protected void Item_Command(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TextBox box = (TextBox)e.Item.FindControl("myTextBox");
if(box != null)
{
Response.Write(box.Text);
}
}protected void BindGrid()
{
dg.DataSource = new string[]{"a","a","a","a","a","a"};
dg.DataBind();
}protected void Page_Load(Object sender, EventArgs e)
{
if(!IsPostBack)
{
BindGrid();
}
}</script>
</head>
<body>
<form id="aa" runat="server"><asp:datagrid id="dg" runat="server"
OnItemCreated="Item_Created"
OnItemCommand="Item_Command"
AutoGenerateColumns="False">
<Columns>
<asp:ButtonColumn Text="我是按钮,按我一下" ButtonType="PushButton" CommandName="push"></asp:ButtonColumn>
</Columns>
</asp:datagrid></form>
</body>
</html>