【发布时间】:2015-05-21 02:18:47
【问题描述】:
我有一个中继器,我使用标签进行显示,并使用一个隐藏的文本框来保存相同的值。现在我想启用文本框,以便用户可以编辑表/中继器中的输入。谁能帮我?下面是我的代码
public void FillTable()
{
DataTable table = new DataTable();
using (MySqlConnection conn = Functions.GetConnection())
{
string sql = "SELECT FirstName, LastName from tbluser LIMIT 15";
using (MySqlCommand cmd = new MySqlCommand(sql, conn))
{
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(table);
conn.Close();
}
}
asd.DataSource = table;
asd.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
asd.Visible = true;
}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
RepeaterItem item = e.Item;
Literal lblname = (Literal)item.FindControl("Label2");
TextBox txtbox = (TextBox)item.FindControl("Label3");
if (e.CommandName == "EDIT")
{
lblname.Visible = false;
txtbox.Visible = true;
【问题讨论】:
-
我找到了解决方案,我使用引导模式编辑表中的记录(asp.net 中继器)。在 itemCommand 事件中,我获取 ID 并检索该记录,然后绑定到模式文本框中。但是,如果有内联方法,我想知道。干杯,
标签: c# asp.net repeater itemtemplate