By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,277 Members | 1,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,277 IT Pros & Developers. It's quick & easy.

How to textbox value from datagrid header template

P: 92
Hi,

I have datagrid control. In that I place textbox, insert link button in hearder template. When I click that Insert button the value from textbox should be loaded into grid. I am capturing at rowcommand()

here the code:
Expand|Select|Wrap|Line Numbers
  1. If e.CommandName = "Insert" Then
  2.             Dim t1 As TextBox
  3.             t1 = CType(e.Item.FindControl("phasetxt"), TextBox)
  4.             Dim t2 As TextBox
  5.             t2 = CType(e.Item.FindControl("phasevaltxt"), TextBox)
  6.             Dim ii As Integer
  7.             objt = Session("dt")
  8.             Dim fg As Boolean = True
  9.             For ii = 0 To objt.Rows.Count - 1
  10.                 If objt.Rows(ii).Item("phase_desc") = t1.Text.Trim Then
  11.                     fg = False
  12.                 End If
  13.             Next
  14.             If fg = True Then
  15.                 Dim nrow As DataRow
  16.                 nrow = objt.NewRow
  17.                 nrow("phase_desc") = t1.Text.Trim
  18.                 nrow("phase_value") = t2.Text
  19.                 objt.Rows.Add(nrow)
  20.                 objt.AcceptChanges()
  21.                 Session("dt") = objt
  22.                 grdData.DataSource = objt
  23.                 grdData.DataBind()
  24.             Else
  25.                 Dim strretval As String
  26.                 strretval = "window.alert('Phase Description Already Added');"
  27.                 Page.ClientScript.RegisterStartupScript(Me.GetType(), "passval", strretval, True)
  28.             End If
  29.         End If
but when I retriving textbox value it always give empty value only. how can I achieve this.
Aug 14 '10 #1
Share this Question
Share on Google+
1 Reply


Frinavale
Expert Mod 5K+
P: 9,731
Please post your Page Load method...
If you are calling your GridView.DataBind method in your Page Load method then you will replace any information your user provided with "nothing".


-Frinny
Aug 16 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.