V
vinod babu via .NET 247
(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
--------------------------------
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