grid view RowUpdating problem

M

merco

Hi.

I have some problems using gridview bind to a datatable: i can't get
updated values in then RowUpdating : i think the problem is that the
datasource is nothing...
I'm not using visual datasources due to the complex sql string and
different database targets.

Is it possible to get new values from RowUpdating ?


This is the code:
Partial Class Soggetti
Inherits System.Web.UI.Page
Private Dt As Data.DataTable
Private Dr As Data.DataRow
Private Dtc As Data.DataTable
Private Sub RebindCOntatti()
Dtc = MainClass.GetDtContatti(Session("Par"),
Me.CodiceTextBox.Text)
Me.GridContatti.DataSource = Dtc

Me.GridContatti.DataBind()
End Sub
Private Sub VuotaCampi()
Me.CodiceTextBox.Text = ""
Me.CodiceNascosto.Value = ""
Me.RagSocTextBox.Text = ""
Me.PIVATextBox.Text = ""
Me.GridContatti.DataSource = Nothing



End Sub
Private Sub RiempiCampi()
VuotaCampi()
If Not IsNothing(Dr) Then
Me.CodiceTextBox.Text = MainClass.Nz(Dr("Cliente"), "")
Me.CodiceNascosto.Value = MainClass.Nz(Dr("Cliente"), "")
Me.RagSocTextBox.Text = MainClass.Nz(Dr("RagSociale"), "")
Me.PIVATextBox.Text = MainClass.Nz(Dr("PIVA"), "")
Me.IndiTextBox.Text = MainClass.Nz(Dr("Indirizzo"), "")
MainClass.SetComboValue(Dr, "Lingua",
Me.LinguaDropDownList)
MainClass.SetComboValue(Dr, "CodValuta",
Me.ValutaDropDownList)
MainClass.SetComboValue(Dr, "CodListino",
Me.ListinoDropDownList)
MainClass.SetComboValue(Dr, "CodListinoRicambio",
Me.ListinoRicambiDropDownList)
MainClass.SetComboValue(Dr, "CodScontoQtaPrRicambio",
Me.ListinoQtaDropDownList)


RebindCOntatti()

End If
End Sub


Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dt = Nothing
Dr = Nothing
If Not Me.IsPostBack Then
MainClass.PopolaCBValute(Session("Par"),
Me.ValutaDropDownList)
MainClass.PopolaCBListino(Session("Par"),
Me.ListinoDropDownList)
MainClass.PopolaCBListino(Session("Par"),
Me.ListinoRicambiDropDownList)
MainClass.PopolaCBLingua(Session("Par"),
Me.LinguaDropDownList)
Else


If Me.CodiceNascosto.Value <> "" Then
Dt = MainClass.FindDTSoggetti(Session("Par"),
Me.CodiceNascosto.Value, "", True)
If Not IsNothing(Dt) Then
If Dt.Rows.Count > 0 Then
Dr = Dt.Rows(0)
End If
End If
RiempiCampi()

End If

End If
End Sub

Protected Sub SaveButton_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles SaveButton.Click
MainClass.SalvaCliente(Session("Par"), Me.CodiceTextBox.Text,
Me.RagSocTextBox.Text, Me.IndiTextBox.Text, Me.PIVATextBox.Text,
Me.ValutaDropDownList.SelectedValue,
Me.LinguaDropDownList.SelectedValue,
Me.ListinoDropDownList.SelectedValue,
Me.ListinoRicambiDropDownList.SelectedValue, Me.PrzTextBox.Text,
Me.ScoTextBox.Text, Me.ListinoQtaDropDownList.SelectedValue)
Me.CodiceNascosto.Value = Me.CodiceTextBox.Text

End Sub

Protected Sub NewButton_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles NewButton.Click
Me.CodiceTextBox.Text = ""
Me.CodiceNascosto.Value = ""
VuotaCampi()
End Sub

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LinkButton1.Click
Mw.ActiveViewIndex = 0

End Sub

Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LinkButton2.Click
Mw.ActiveViewIndex = 1
RebindCOntatti()
End Sub

Protected Sub GridContatti_PageIndexChanging(ByVal sender As
Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
Handles GridContatti.PageIndexChanging
Me.GridContatti.PageIndex = e.NewPageIndex
Me.GridContatti.Page.DataBind()
End Sub

Protected Sub GridContatti_RowCancelingEdit(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs)
Handles GridContatti.RowCancelingEdit
GridContatti.EditIndex = -1
RebindCOntatti()
Me.Mw.ActiveViewIndex = 1
End Sub

Protected Sub GridContatti_RowCommand(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
GridContatti.RowCommand

End Sub

Protected Sub GridContatti_RowEditing(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles
GridContatti.RowEditing
Me.Mw.ActiveViewIndex = 1
Me.CodiceNascosto.Value = ""

Me.GridContatti.Attributes.Add("OldValuesParameterFormatString",
"original_{0}")
Me.GridContatti.EditIndex = e.NewEditIndex
RebindCOntatti()
Me.Mw.ActiveViewIndex = 1
End Sub

Protected Sub GridContatti_RowUpdating(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
GridContatti.RowUpdating
Dim S As String = ""
Dim I As Integer = e.RowIndex
Dim C, Se, CC, N, T, F, em, CE As String

Me.Mw.ActiveViewIndex = 1
'RebindCOntatti()
'Me.GridContatti.EditIndex = I
C = MainClass.GetGridCellValue(Me.GridContatti, I, 0)
Se = MainClass.GetGridCellValue(Me.GridContatti, I, 2)
CC = MainClass.GetGridCellValue(Me.GridContatti, I, 3)
N = MainClass.GetGridCellValue(Me.GridContatti, I, 4)
T = MainClass.GetGridCellValue(Me.GridContatti, I, 5)
F = MainClass.GetGridCellValue(Me.GridContatti, I, 6)
em = MainClass.GetGridCellValue(Me.GridContatti, I, 7)
CE = MainClass.GetGridCellValue(Me.GridContatti, I, 8)


'MainClass.SalvaContatto(Session("Par"), C, Se, CC, N, T, F,
em, CE)




End Sub
End Class
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top