Gridveiw包含templatefield,因为文本框值没有正在恢复。它给出了空值 [英] Gridveiw contain templatefield as textbox value is not retriving. Its giving null value

查看:73
本文介绍了Gridveiw包含templatefield,因为文本框值没有正在恢复。它给出了空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含图像和名称的gridview和一个文本框。它正确加载gridview。无法检索文本框的值。下面是我的代码,请帮帮我



I have one gridview that contains image and name and one textbox. its loading gridview properly. Not able to retrive the value of textbox. Below is my code please help me

foreach (GridViewRow items in OrderItemsGrid.Rows)
            {

                 //int.Parse(items.Cells[0].Text);
                 itemid =     Convert.ToInt32(((Label)items.FindControl("lblItemId")).Text);
                TextBox txt = (TextBox)items.FindControl("TxtQuantity");
                //txt.ID = "txt" + "_" + count.ToString();
                
                int quantity = Convert.ToInt32(txt.Text);
                string sql_insert = string.Format("insert into OrderDetails(OrderId,ItemId,Quantity)values('{0}','{1}','{2}')", orderid, itemid, quantity);
                obj.Do_Transaction(sql_insert);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "alert(' Order done Successfully')", true);
            }

推荐答案

如果你能够访问标签的内容,那么你的名字可能有问题文本框而不是TxtQuantity,它可能是txtQuantity
if u r able to access the content of the label, then there could be problem in the name of ur textbox like Instead of "TxtQuantity" , it could be "txtQuantity"


这篇关于Gridveiw包含templatefield,因为文本框值没有正在恢复。它给出了空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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