我有一个转发器,我使用标签进行显示,隐藏文本框保存相同的值。现在我想启用文本框,以便用户可以编辑表/转发器中的输入。谁能帮我?下面是我的代码
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;
答案 0 :(得分:0)
您没有获得文本框,而是获得标签两次:
TextBox txtbox = (TextBox)item.FindControl("Label3");