Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何通过itemCommand启用Repeater的itemtemplate中的所有textbox控件?_C#_Asp.net_Repeater_Itemtemplate - Fatal编程技术网

C# 如何通过itemCommand启用Repeater的itemtemplate中的所有textbox控件?

C# 如何通过itemCommand启用Repeater的itemtemplate中的所有textbox控件?,c#,asp.net,repeater,itemtemplate,C#,Asp.net,Repeater,Itemtemplate,我有一个转发器,我用标签显示,还有一个隐藏的文本框,里面有相同的值。现在我想启用文本框,以便用户可以编辑表/中继器中的输入。有人能帮我吗?下面是我的代码 public void FillTable() { DataTable table = new DataTable(); using (MySqlConnection conn = Functions.GetConnection()) { string sql = "SELECT FirstName,

我有一个转发器,我用标签显示,还有一个隐藏的文本框,里面有相同的值。现在我想启用文本框,以便用户可以编辑表/中继器中的输入。有人能帮我吗?下面是我的代码

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;

您获得的不是文本框,而是两次标签:

 TextBox txtbox = (TextBox)item.FindControl("Label3");

我找到了一个解决方案,我使用引导模式在我的tableasp.net repeater中编辑了一条记录。在itemCommand事件中,我获取ID并检索该记录,然后绑定到模式文本框中。但是,如果有内联方法,我想知道它。干杯