datalist:דפדוף+update

  • פותח הנושא inza
  • פורסם בתאריך

inza

New member
datalist:דפדוף+update

יש לי dataList שמימשתי עם דפדוף ועם אפשרות עריכה.הבעיה היא שהדפדוף מתנגש עם העריכה: לצורך הדפדוף אין צורך לכתוב בפונקציה pageLode : if Not Page.IsPostBack , אבל בשביל העריכה אני חייבת להוסיף זאת.ואני לא יודעת איך לפצל את קישור הנתונים <script language="VB" runat="server"> Dim pagedData As New pagedDataSource dim Conn as new OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:RealityDATA.mdb") Sub Page_Load(byVal obj As Object, byVal e As EventArgs) ' if Not Page.IsPostBack then doPaging() 'end if End Sub Function getTheData() As DataTable Dim DS As New DataSet() dim sqlStr as String sqlStr="SELECT * FROM SekerSikunimWorkers" Dim objAdapter As New OleDbDataAdapter(sqlStr, Conn) objAdapter.Fill(DS, "SekerSikunimWorkers") Return DS.Tables("SekerSikunimWorkers").Copy End Function Sub doPaging() pagedData.DataSource = getTheData().DefaultView pagedData.AllowPaging = True pagedData.PageSize = 1 Try pagedData.CurrentPageIndex = Int32.Parse(Request.QueryString("Page")).ToString() Catch ex As Exception pagedData.CurrentPageIndex = 0 End Try btnPrev.Visible = ( NOT pagedData.IsFirstPage ) btnNext.Visible = ( NOT pagedData.IsLastPage ) pageNumber.Text = pagedData.PageCount & " <- " & (pagedData.CurrentPageIndex + 1) theDataList.DataSource = pagedData theDataList.DataBind() End Sub אשמח לכל פתרון-אני יושבת על זה הרבה זמן! תודה רבה
 

inza

New member
פונקציית update

Sub Update_Command(ByVal sender As Object, _ ByVal e As DataListCommandEventArgs) Dim tbox As TextBox Dim sSekerSikunimID, sFollow,sDone,sDate,sExist,sProffesion As String Dim sActs as string Dim price As Single '---retrieves the key for the row--- sSekerSikunimID = theDataList.DataKeys(e.Item.ItemIndex) response.write("sSekerSikunimID=" & sSekerSikunimID & "<br>") '---find the textbox control containing the tbFollowBy sFollow = CType(e.Item.FindControl("tbFollowBy"), TextBox).Text response.write("sFollow=" & sFollow & "<br>") ' exit sub '---find the textbox control containing the tbDoneBy sDone = (CType(e.Item.FindControl("tbDoneBy"), TextBox)).Text response.write("tbDoneBy=" & CType(e.Item.FindControl("tbDoneBy"), TextBox).Text & "<br>") '---find the textbox control containing the cbExist 'sExist = CType(e.Item.FindControl("cbExist"), checkBox).checked 'response.write("sFollow=" & sFollow & "<br>") '---find the textbox control containing the tbDate sDate = CType(e.Item.FindControl("tbDate"), TextBox).Text response.write("tbDate=" & sDate & "<br>") '---find the textbox control containing the tbProffesion sProffesion = CType(e.Item.FindControl("tbProffesion"), TextBox).Text response.write("tbProffesion=" & sProffesion & "<br>") '---find the textbox control containing the tbActs sActs = CType(e.Item.FindControl("tbActs"), TextBox).Text response.write("tbActs=" & sActs & "<br>") exit sub 'Define our sql query Dim sSQL As String = "UPDATE SekerSikunimWorkers SET " & _ "SekerAct = @acts," & _ "SekerDate = @date," & _ "SekerBy = @by," & _ "SekerMaakav = @maakav," & _ "SekerWorker = @worker" & _ " WHERE SekerSikunimID = @id" Dim comm As New OleDbCommand(sSQL, Conn) 'Add up the parameter, associated it with its value comm.Parameters.Add("@acts", sActs) comm.Parameters.Add("@date", sDate) comm.Parameters.Add("@by", sDone) comm.Parameters.Add("@maakav", sFollow) comm.Parameters.Add("@worker", sProffesion) comm.Parameters.Add("@id", sSekerSikunimID) conn.Open() comm.ExecuteNonQuery() 'Dim drSS As OleDbDataReader = comm.ExecuteReader() response.write(sSQL) exit sub conn.Close() 'drSS.Close() theDataList.EditItemIndex = -1 doPaging() End Sub
 
למעלה