odiseh
شنبه 30 شهریور 1387, 13:44 عصر
سلام بچه ها
من یه فرم دارم که توش یه گریدویو هستش و یه ObjectDataSource
توی فرم من داخل خود GridView هم امکان Add گذاشتم و هم امکان Edit و هم امکان Delete.
اما Update و Delete من کار نمی کنه...ولی Add مشکلی نداره.
اینم کد من ::
Protected Sub grdE_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventA rgs) Handles grdE.RowCancelingEdit
grdE.EditIndex = -1
End Sub
Protected Sub grdE_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles grdE.RowCommand
Select Case e.CommandName.ToUpper
Case "ADD"
ods1.Insert()
End Select
End Sub
Protected Sub grdE_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdE.RowCreated
If GridIsEmpty Then
With e.Row
If .RowType = DataControlRowType.DataRow Then
.Controls.Clear()
.Visible = False
End If
End With
Else
With e.Row
If .RowType = DataControlRowType.DataRow Then
If CType(.FindControl("drpInterestEditItem"), DropDownList) IsNot Nothing Then
CType(.FindControl("drpInterestEditItem"), DropDownList).SelectedValue = ViewState("RowEditingInterestDropDownListValue")
End If
End If
End With
End If
End Sub
Protected Sub ods1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEv entArgs) Handles ods1.Updating
e.InputParameters("lID") = CType(grdE.DataKeys.Item(grdE.EditIndex).Value, Int32)
e.InputParameters("lInterestID") = CType((grdE.Rows(grdE.EditIndex).FindControl("drpInterestEditItem")), DropDownList).SelectedValue
e.InputParameters("sDescription") = CType((grdE.Rows(grdE.EditIndex).FindControl("txtInterestDescriptionEditItem")), TextBox).Text.Trim
End Sub
Protected Sub grdE_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles grdE.RowDeleting
ViewState("RowDeletingIndex") = e.RowIndex
End Sub
Protected Sub grdE_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grdE.RowEditing
grdE.EditIndex = e.NewEditIndex
ViewState("RowEditingInterestDropDownListValue") = Convert.ToInt16(CType(grdE.Rows(grdE.EditIndex).Fi ndControl("lblInterestID"), Label).Text)
End Sub
اونایی که کار کرده اند لطفا راهنمایی کنن......با تشکر
من یه فرم دارم که توش یه گریدویو هستش و یه ObjectDataSource
توی فرم من داخل خود GridView هم امکان Add گذاشتم و هم امکان Edit و هم امکان Delete.
اما Update و Delete من کار نمی کنه...ولی Add مشکلی نداره.
اینم کد من ::
Protected Sub grdE_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventA rgs) Handles grdE.RowCancelingEdit
grdE.EditIndex = -1
End Sub
Protected Sub grdE_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles grdE.RowCommand
Select Case e.CommandName.ToUpper
Case "ADD"
ods1.Insert()
End Select
End Sub
Protected Sub grdE_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdE.RowCreated
If GridIsEmpty Then
With e.Row
If .RowType = DataControlRowType.DataRow Then
.Controls.Clear()
.Visible = False
End If
End With
Else
With e.Row
If .RowType = DataControlRowType.DataRow Then
If CType(.FindControl("drpInterestEditItem"), DropDownList) IsNot Nothing Then
CType(.FindControl("drpInterestEditItem"), DropDownList).SelectedValue = ViewState("RowEditingInterestDropDownListValue")
End If
End If
End With
End If
End Sub
Protected Sub ods1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEv entArgs) Handles ods1.Updating
e.InputParameters("lID") = CType(grdE.DataKeys.Item(grdE.EditIndex).Value, Int32)
e.InputParameters("lInterestID") = CType((grdE.Rows(grdE.EditIndex).FindControl("drpInterestEditItem")), DropDownList).SelectedValue
e.InputParameters("sDescription") = CType((grdE.Rows(grdE.EditIndex).FindControl("txtInterestDescriptionEditItem")), TextBox).Text.Trim
End Sub
Protected Sub grdE_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles grdE.RowDeleting
ViewState("RowDeletingIndex") = e.RowIndex
End Sub
Protected Sub grdE_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grdE.RowEditing
grdE.EditIndex = e.NewEditIndex
ViewState("RowEditingInterestDropDownListValue") = Convert.ToInt16(CType(grdE.Rows(grdE.EditIndex).Fi ndControl("lblInterestID"), Label).Text)
End Sub
اونایی که کار کرده اند لطفا راهنمایی کنن......با تشکر