【问题标题】:Couldn't get values of textbox from footer row of gridview无法从 gridview 的页脚行获取文本框的值
【发布时间】:2013-10-24 09:29:06
【问题描述】:

实际上我的问题是我想在 gridview 的页脚行中插入新行,同时单击 gridview 之外的按钮,我无法在 gridview 的页脚行中获取文本框的值

我的编码是

Dim footerRow As GridViewRow = grvTBD_LoanProducts.FooterRow
Dim sStateCode As String = TryCast(footerRow.FindControl("txtStateCode"), TextBox).Text
Dim sEntryTypeID As String = TryCast(footerRow.FindControl("txtEntryTypeID"),TextBox).Text

上面的编码不起作用,请帮助我修复它,提前谢谢

【问题讨论】:

  • “没有用”是什么意思?如果出现任何错误,请更具体地说明您的问题并添加错误日志。
  • 变量 sStateCode 是 "" 它不包含我在 txtstatecode 中输入的值

标签: asp.net gridview vb.net-2010


【解决方案1】:

试试这个代码,它可能会工作:

Protected Sub GridView1_RowCommand(sender As Object, e As GridViewCommandEventArgs)
    Dim txtName As TextBox = TryCast(GridView1.FooterRow.FindControl("txtStateCode"), TextBox)
    Dim aa As String = txtName.Text
End Sub

【讨论】:

  • 但我希望此代码位于 gridview 之外的按钮的 click_Event 中。它会起作用吗?
  • 在按钮点击内尝试这两行:- Dim txtName As TextBox = TryCast(GridView1.FooterRow.FindControl("txtStateCode"), TextBox) Dim aa As String = txtName.Text
  • 你能试试这个吗:- Dim sStateCode As String = GridView1.FooterRow.Cells[0].Text
  • 但是感谢您宝贵的时间:)
  • 终于找到了解决方案,我在 Page_Load 的 Not IsPostBack 方法之外给出了 loaddata()。现在它工作正常,谢谢你 Arul Dinesh 的回复
猜你喜欢
  • 1970-01-01
  • 2015-11-23
  • 2011-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多