cannot save the dropdownlist data to datagrid. iam new to .net, help me out please iam struck up her

Discussion in 'ASP .Net' started by vinod babu via .NET 247, Sep 23, 2004.

  1. (Type your message here)

    --------------------------------
    From: vinod babu

    Here my adding a new row code

    Private Sub cmdadd1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdadd1.Click
    If DataExists() = False Then Exit Sub
    MaintenancereportDataSet = DataRetrieve()
    Dim rowNew As System.Data.DataRow = MaintenancereportDataSet.Tables(0).NewRow
    pre = Mid(txtreportno.Text, 1, 2)
    result = pre + "1"
    checkId1(result)
    Session("type2") = UCase(resultFinal)
    rowNew.Item("SLNO") = type2
    rowNew.Item("MDENGR") = type2
    MaintenancereportDataSet.Tables(0).Rows.Add(rowNew)
    MaintenanceGrid.EditItemIndex = MaintenanceGrid.Items.Count
    MaintenanceGrid.DataSource = MaintenancereportDataSet
    MaintenanceGrid.DataBind()
    DataSave(MaintenancereportDataSet)
    empnam()
    End Sub
    where every thing fine working out it got edited row with the dropdownlist with the data, but i have a problem of saving
    this is my procedure to save the data. here i need a procedure to get the datatextfield value and store it to database.

    Private Sub cmdUpdate1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate1.Click
    Try
    If DataExists() = False Then Exit Sub
    If MaintenanceGrid.EditItemIndex = -1 Then Exit Sub
    Dim intCount As Integer
    Dim MaintenancereportDataSet As DataSet = DataRetrieve()
    With MaintenanceGrid
    For intCount = 1 To .Items(.EditItemIndex).Cells.Count
    If intCount = .Items(.EditItemIndex).Cells.Count _
    Then Exit For
    ' Check that a control exists in this position
    If .Items(.EditItemIndex).Cells(intCount).Controls. _
    Count Then
    ' Check for a standard TextBox
    If TypeOf (.Items(.EditItemIndex).Cells(intCount). _
    Controls(0)) _
    Is TextBox Then
    Dim strValue As String = CType(.Items(. _
    EditItemIndex). _
    Cells(intCount).Controls(0), TextBox).Text
    If strValue <> "" Then
    ' This isn't null, so store value
    MaintenancereportDataSet.Tables(0).Rows(.EditItemIndex).Item( _
    intCount - 1) = strValue
    If intCount = 9 Then
    Session("extracharge") = UCase(strValue)
    End If
    ElseIf intCount = 1 Then
    MaintenancereportDataSet.Tables(0).Rows(.EditItemIndex).Item( _
    intCount - 1) = Session("type2")
    ElseIf intCount = 2 Then
    MaintenancereportDataSet.Tables(0).Rows(.EditItemIndex).Item( _
    intCount - 1) = txtreportno.Text
    ElseIf intCount = 3 Then
    MaintenancereportDataSet.Tables(0).Rows(.EditItemIndex).Item( _
    intCount - 1) = txtcusid.Text
    Else
    ' Treat empty value as null
    MaintenancereportDataSet.Tables(0).Rows(.EditItemIndex).Item( _
    intCount - 1) = System.DBNull.Value
    End If
    End If
    End If
    Next
    .SelectedIndex = -1
    .EditItemIndex = -1
    DataSave(MaintenancereportDataSet)
    .DataSource = MaintenancereportDataSet
    .DataBind()
    End With
    Catch
    lblmsg.Text = Err.Description
    End Try
    End Sub

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>D/4Z22zpwUO67odNEHBmyQ==</Id>
     
    vinod babu via .NET 247, Sep 23, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pavi

    Struck with System command

    pavi, May 22, 2007, in forum: C Programming
    Replies:
    3
    Views:
    346
    Guru Jois
    May 23, 2007
  2. ali khanbaba
    Replies:
    0
    Views:
    336
    ali khanbaba
    May 21, 2009
  3. M. Kemal
    Replies:
    0
    Views:
    118
    M. Kemal
    Sep 22, 2003
  4. Replies:
    4
    Views:
    112
    John Blessing
    Apr 2, 2004
  5. VbUser25
    Replies:
    0
    Views:
    108
    VbUser25
    Jan 27, 2005
Loading...

Share This Page