需要DataList TextBox的帮助 [英] Need Help with DataList TextBox

查看:68
本文介绍了需要DataList TextBox的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在编辑项目模板中有一个文本框的数据列表,我可以设置txtbox的文本属性,但每当我运行我的应用程序并在文本框中键入内容并运行我的updatye命令时,文本框文本为空或null 。



这是我的updatye命令



I have a datalist that has a textbox in the edit item template and i can set the text propery of the txtbox but whenever I run my app and type something in the textbox and run my updatye command the textbox text is empty or null.

here is my updatye command

protected void Update(object source, DataListCommandEventArgs e)
{
    if (!IsPostBack)
    {
        DataList1.DataBind();

        SqlCommand cmd1 = new SqlCommand("Update install_Add_Test set installName = '" + ((TextBox)e.Item.FindControl("editInstallName")).Text.ToString() + "' where id = '1'", cs);
        cs.Open();
        cmd1.ExecuteNonQuery();
        //Response.Write(editInstallName);


        cs.Close();
        //Response.Redirect("DatalistTest.aspx");
        //DataList1.DataBind();

        DataList1.EditItemIndex = -1;

    }





我不想把我的所有代码放在这里发布,但如果我需要,我可以。看起来每当我在其中键入内容并点击我的更新链接按钮时,textbox.txt值就会发生变化。如果需要更多信息,请告诉我。在此先感谢。



I didn''t want to put all of my code in this post but if I need to I can. It just seems like the textbox.txt value should change whenever I type something in it and hit my update link button. Please let me know if more info is needed. Thanks in Advance.

推荐答案

Hello Dustin,

尝试删除DataList1.DataBind();

And再试一次
Hello Dustin ,
Try to remove DataList1.DataBind();
And try again


这篇关于需要DataList TextBox的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆