发布时间:2018-12-06编辑:佚名阅读(1822)
1.在Repeater_ItemDataBound事件中设置按钮的CommandArgument:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView dv = (DataRowView)e.Item.DataItem; ((Button)e.Item.FindControl("Button1")).CommandName = "change"; ((Button)e.Item.FindControl("Button1")).CommandArgument = dv.Row["Id"].ToString(); } }
2.在Repeater_ItemCommand事件中获取值:
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "change") { string Id = e.CommandArgument.ToString(); TextBox box = Repeater1.Items[e.Item.ItemIndex].FindControl("TextBox1") as TextBox; string txt = box.Text; } }
关键字: 点击 Repeater 按钮 获取 TextBox 值
上一篇:asp.net刷新页面
1人
0人
0人
0人