e.Row.Cells[相关的列].HasControls()在调试的时候 永远都是false
我在第四个单元格添加料删除 和更新的
e.Row.Cells[2].HasControls()
false
e.Row.Cells[1].HasControls()
false
e.Row.Cells[0].HasControls()
false
e.Row.Cells[5].HasControls()
本来是用javascript添加客户端事件的
我在第四个单元格添加料删除 和更新的
e.Row.Cells[2].HasControls()
false
e.Row.Cells[1].HasControls()
false
e.Row.Cells[0].HasControls()
false
e.Row.Cells[5].HasControls()
本来是用javascript添加客户端事件的
解决方案 »
- 有没有人做过asp.net进度条 swfUpload呀,求救。。
- 如何修改asp.net网站的页面(有aspx,dll,cs文件)
- 请教SQL Server查询特定日,月,季度,年的SQL语句(另还问报表打印,模态窗体是否不能实现IE的自身打印控制?)
- asp.net(一般处理程序) 中关于Session 的问题
- 关于注册页面中的密码确认功能如何实现?在线等。。。。。
- 请幕白兄进来看看还是那个模式对话框刷新的问题!~!~
- 网站多刷新几下就出现错误
- 不能修改asp.net version
- Wizard控件如何能停在step2? 我在CSDN提的问题没有一个能得到解决,高手帮忙啊
- RadioButtonList的问题
- 怎样在页面上弹出新窗口?
- 今天遇到了 Asp.Net身份验证—Form验证 一个问题,高手进
public partial class Admin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["username"] != null || Session["userpwd"] != null)
{
string username = Convert.ToString(Session["username"]);
string userpwd = Convert.ToString(Session["userpwd"]);
if (Users.validateuser(username,userpwd))
{
Label1.Text = username;
}
else
{
Response.Redirect("login.aspx");
} }
else
{
Response.Redirect("login.aspx");
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.Cells[3].HasControls())
{
//LinkButton linkdelete =(LinkButton)e.Row.Cells[0].Controls[1];
LinkButton linkupdate = (LinkButton)e.Row.Cells[0].Controls[0];
if (linkupdate.Text.Equals("删除"))
{
linkupdate.Attributes.Add("onclick", "javascript:return confirm('" + string.Format("你确认要删除管理员{0}吗", DataBinder.Eval(e.Row.DataItem, "username")) + "')");
}
}
}
}
http://dotnet.aspx.cc/article/0e8fdeb4-c461-4f44-9933-672a7510097a/read.aspx
Row.Cells[].FindControl[]是模板列查找!
楼主是模板列还是非模板列??
if(e.Row.RowType==DataControlRowType.DataRow)
{
(e.Row.FindControl["LinkButton1"] as LinkButton).Attributes.Add("onclick", "javascript:return confirm('" + string.Format("你确认要删除管理员{0}吗", DataBinder.Eval(e.Row.DataItem, "username")) + "')");
}FindControl[里面是删除按钮的Id]
只要判断那一列是不是数据行就可以了,如果是数据行就查找
dataGridView1.Columns[e.ColumnIndex].Name == "LinkButton1";