msout
asked on
update gridview row programmatically
I have an SQL 6.5 server database table. I need to update row this is my code
Public Sub BindGrid()
Dim ds As DataSet = Regulated.GetRegulatedPara meters
Dim dtParams As DataTable = ds.Tables(0)
Session("dtParams") = dtParams
Gridview1.DataSource = Session("dtParams")
Gridview1.DataBind()
End Sub
Protected Sub Gridview1_RowUpdating(ByVa l sender As Object, ByVal e As GridViewUpdateEventArgs)
Dim dt = CType(Session("dtParams"), DataTable).
Dim row = Gridview1.Rows(e.RowIndex)
dt.Rows(row.DataItemIndex) ("Paramete rId") = (CType(row.FindControl("lb lParameter Id"), Label)).Text
dt.Rows(row.DataItemIndex) ("ParamNam e") = (CType(row.FindControl("tx tParamName "), TextBox)).Text
dt.Rows(row.DataItemIndex) ("mnemonic ") = (CType(row.FindControl("tx tmnemonic" ), TextBox)).Text
dt.Rows(row.DataItemIndex) ("Conditio n1Min") = (CType(row.FindControl("tx tCondition 1Min"), TextBox)).Text
dt.Rows(row.DataItemIndex) ("Level1Mi n") = (CType(row.FindControl("tx tLevel1Min "), TextBox)).Text
dt.Rows(row.DataItemIndex) ("Conditio n0Min") = (CType(row.FindControl("tx tCondition 0Min"), TextBox)).Text
If (CType(row.FindControl("tx tLevel0Min "), TextBox)).Text <> "" Then
dt.Rows(row.DataItemIndex) ("Level0Mi n") = (CType(row.FindControl("tx tLevel0Min "), TextBox)).Text
Else
dt.Rows(row.DataItemIndex) ("Level0Mi n") = DBNull.Value
End If
dt.Rows(row.DataItemIndex) ("Conditio n0Max") = (CType(row.FindControl("tx tCondition 0Max"), TextBox)).Text
If (CType(row.FindControl("tx tLevel0Max "), TextBox)).Text <> "" Then
dt.Rows(row.DataItemIndex) ("Level0Ma x") = (CType(row.FindControl("tx tLevel0Max "), TextBox)).Text
Else
dt.Rows(row.DataItemIndex) ("Level0Ma x") = DBNull.Value
End If
dt.Rows(row.DataItemIndex) ("Conditio n1Max") = (CType(row.FindControl("tx tCondition 1Max"), TextBox)).Text
If (CType(row.FindControl("tx tLevel1Max "), TextBox)).Text <> "" Then
dt.Rows(row.DataItemIndex) ("Level1Ma x") = (CType(row.FindControl("tx tLevel1Max "), TextBox)).Text
Else
dt.Rows(row.DataItemIndex) ("Level0Ma x") = DBNull.Value
End If
If (CType(row.FindControl("tx tMCL"), TextBox)).Text <> "" Then
dt.Rows(row.DataItemIndex) ("Level1Ma x") = (CType(row.FindControl("tx tMCL"), TextBox)).Text
Else
dt.Rows(row.DataItemIndex) ("MCL") = DBNull.Value
End If
Gridview1.EditIndex = -1
BindGrid()
End Sub
I do not get any error messages but it does not update the record.
What am I doing wrong?
Thank you in advance
Public Sub BindGrid()
Dim ds As DataSet = Regulated.GetRegulatedPara
Dim dtParams As DataTable = ds.Tables(0)
Session("dtParams") = dtParams
Gridview1.DataSource = Session("dtParams")
Gridview1.DataBind()
End Sub
Protected Sub Gridview1_RowUpdating(ByVa
Dim dt = CType(Session("dtParams"),
Dim row = Gridview1.Rows(e.RowIndex)
dt.Rows(row.DataItemIndex)
dt.Rows(row.DataItemIndex)
dt.Rows(row.DataItemIndex)
dt.Rows(row.DataItemIndex)
dt.Rows(row.DataItemIndex)
dt.Rows(row.DataItemIndex)
If (CType(row.FindControl("tx
dt.Rows(row.DataItemIndex)
Else
dt.Rows(row.DataItemIndex)
End If
dt.Rows(row.DataItemIndex)
If (CType(row.FindControl("tx
dt.Rows(row.DataItemIndex)
Else
dt.Rows(row.DataItemIndex)
End If
dt.Rows(row.DataItemIndex)
If (CType(row.FindControl("tx
dt.Rows(row.DataItemIndex)
Else
dt.Rows(row.DataItemIndex)
End If
If (CType(row.FindControl("tx
dt.Rows(row.DataItemIndex)
Else
dt.Rows(row.DataItemIndex)
End If
Gridview1.EditIndex = -1
BindGrid()
End Sub
I do not get any error messages but it does not update the record.
What am I doing wrong?
Thank you in advance
ASKER
Wonderful!!!! Thank you!!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are getting your data from Regulated.GetRegulatedPara
Your changes are just deleted.
You have to update your Datasource as well in order to get your code function well.
Or you can use Regulated.GetRegulatedPara