服务器控件table,点button 判断是那一行?

[复制链接]
查看11 | 回复3 | 2008-8-25 18:27:10 | 显示全部楼层 |阅读模式
public partial class Test821 : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

bind();



}
}

private void bind()

{

DataSet ds = new BudgetDetailManage().ReadTest820();

for (int i = 0; i < ds.Tables[0].Rows.Count; i++)

{


TableRow row = new TableRow();

TableCell cell1 = new TableCell();

TableCell cell2 = new TableCell();

TableCell cell3 = new TableCell();

TableCell cell4 = new TableCell();

TableCell cell5 = new TableCell();



table1.Rows.Add(row);

row.Cells.Add(cell1);

cell1.Text = ds.Tables[0].Rows["id"].ToString();



row.Cells.Add(cell2);

cell2.Text = ds.Tables[0].Rows["name"].ToString();



row.Cells.Add(cell3);

cell3.Text = Convert.ToDateTime(ds.Tables[0].Rows["date"]).ToString("yyyy-MM-dd");
row.Cells.Add(cell4);

cell4.Text = ds.Tables[0].Rows["price"].ToString();



LinkButton nn = new LinkButton();

nn.Attributes.Add("onclick", "Button1.click(); return false;");



cell5.Controls.Add(nn);


row.Cells.Add(cell5);

nn.Text = "修改";
}

}
protected void Button1_Click(object sender, EventArgs e)

{



// 怎麼判断是那一行?

}

回复

使用道具 举报

千问 | 2008-8-25 18:27:10 | 显示全部楼层
你在创建行的时候应该在每行后面加个按钮,给每个按钮定义不同且累加的id,这样才能判断出是哪一样...
回复

使用道具 举报

千问 | 2008-8-25 18:27:10 | 显示全部楼层
详细点...
回复

使用道具 举报

千问 | 2008-8-25 18:27:10 | 显示全部楼层
好像这样是没有办法得到的,除非你是每行后都有一个按钮...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行