How to textbox value from datagrid header template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • visweswaran2830
    New Member
    • Nov 2009
    • 92

    #1

    How to textbox value from datagrid header template

    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:
    Code:
    If e.CommandName = "Insert" Then
                Dim t1 As TextBox
                t1 = CType(e.Item.FindControl("phasetxt"), TextBox)
                Dim t2 As TextBox
                t2 = CType(e.Item.FindControl("phasevaltxt"), TextBox)
                Dim ii As Integer
                objt = Session("dt")
                Dim fg As Boolean = True
                For ii = 0 To objt.Rows.Count - 1
                    If objt.Rows(ii).Item("phase_desc") = t1.Text.Trim Then
                        fg = False
                    End If
                Next
                If fg = True Then
                    Dim nrow As DataRow
                    nrow = objt.NewRow
                    nrow("phase_desc") = t1.Text.Trim
                    nrow("phase_value") = t2.Text
                    objt.Rows.Add(nrow)
                    objt.AcceptChanges()
                    Session("dt") = objt
                    grdData.DataSource = objt
                    grdData.DataBind()
                Else
                    Dim strretval As String
                    strretval = "window.alert('Phase Description Already Added');"
                    Page.ClientScript.RegisterStartupScript(Me.GetType(), "passval", strretval, True)
                End If
            End If
    but when I retriving textbox value it always give empty value only. how can I achieve this.
    Last edited by Frinavale; Aug 16 '10, 06:52 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Please post your Page Load method...
    If you are calling your GridView.DataBi nd method in your Page Load method then you will replace any information your user provided with "nothing".


    -Frinny

    Comment

    Working...