排序的问题
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Dim Dataview1 As New System.Data.DataView()
Dim ds As New DataSet()
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Dim DropDownList1 As New System.Web.UI.WebControls.DropDownList()
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim InsertStr As String
InsertStr = "select distinct emp_id,fname,lname,job_id from employee "
Dim custDA As System.Data.SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(InsertStr, SqlConnection1)
custDA.Fill(ds, "employee")
Dataview1.Table = ds.Tables("employee")
DataGrid1.DataSource = Dataview1
Dim showtime As String
showtime = Trim(DateString)
Label1.Text = showtime
If Not IsPostBack Then
DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.CancelCommand
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
Dim dr As DataRow
Dim item As String = e.Item.Cells(3).Text
Dim strDel As String
Dim cmdDel As New System.Data.SqlClient.SqlCommand()
strDel = "delete from employee where emp_id='" & item & "'"
SqlConnection1.Open()
cmdDel = New SqlClient.SqlCommand(strDel, SqlConnection1)
cmdDel.ExecuteNonQuery()
'显示数据库
Dim SelectStr As String
SelectStr = "select distinct emp_id,fname,lname,job_id from employee "
Dim cmdSelect As New System.Data.SqlClient.SqlCommand()
cmdSelect = New SqlClient.SqlCommand(SelectStr, SqlConnection1)
cmdSelect.ExecuteNonQuery()
DataGrid1.EditItemIndex = -1
Dataview1.Table = ds.Tables("employee")
DataGrid1.DataSource = Dataview1
DataGrid1.DataBind()
SqlConnection1.Close()
Response.Redirect("webform1.aspx")
End Sub
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
' Dim DropDownList1 As New System.Web.UI.WebControls.DropDownList()
'DropDownList1 = e.Item.Cells(6).Controls(0)
'DropDownList1.DataBind()
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid1.SortCommand
Dataview1.Sort = e.SortExpression
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim emp_id, fname, lname, job_id As String
Dim tb As TextBox
DropDownList1 = e.Item.Cells(6).FindControl("DropDownList1")
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
emp_id = Trim(tb.Text)
tb = CType(e.Item.Cells(4).Controls(0), TextBox)
fname = Trim(tb.Text)
tb = CType(e.Item.Cells(5).Controls(0), TextBox)
lname = Trim(tb.Text)
job_id = Trim(DropDownList1.SelectedItem.Text)
'更新数据库
Dim Updatestr As String
Dim cmdUpdate As New System.Data.SqlClient.SqlCommand()
Updatestr = "Update employee set fname ='" & fname & "',lname='" & _
lname & "',job_id='" & job_id & "' where emp_id ='" & emp_id & "'"
SqlConnection1.Open()
cmdUpdate = New SqlClient.SqlCommand(Updatestr, SqlConnection1)
cmdUpdate.ExecuteNonQuery()
'显示数据库
Dim SelectStr As String
SelectStr = "select distinct emp_id,fname,lname,job_id from employee "
Dim cmdSelect As New System.Data.SqlClient.SqlCommand()
cmdSelect = New SqlClient.SqlCommand(SelectStr, SqlConnection1)
cmdSelect.ExecuteNonQuery()
DataGrid1.EditItemIndex = -1
Dataview1.Table = ds.Tables("employee")
DataGrid1.DataSource = Dataview1
DataGrid1.DataBind()
SqlConnection1.Close()
Response.Redirect("webform1.aspx")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Attributes.Add("onclick", "javascript:return confirm('click me');")
'Response.Redirect("http://www.google.com")
End Sub
编辑的时候不是我想要编辑的内容
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Dim Dataview1 As New System.Data.DataView()
Dim ds As New DataSet()
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Dim DropDownList1 As New System.Web.UI.WebControls.DropDownList()
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim InsertStr As String
InsertStr = "select distinct emp_id,fname,lname,job_id from employee "
Dim custDA As System.Data.SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(InsertStr, SqlConnection1)
custDA.Fill(ds, "employee")
Dataview1.Table = ds.Tables("employee")
DataGrid1.DataSource = Dataview1
Dim showtime As String
showtime = Trim(DateString)
Label1.Text = showtime
If Not IsPostBack Then
DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.CancelCommand
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
Dim dr As DataRow
Dim item As String = e.Item.Cells(3).Text
Dim strDel As String
Dim cmdDel As New System.Data.SqlClient.SqlCommand()
strDel = "delete from employee where emp_id='" & item & "'"
SqlConnection1.Open()
cmdDel = New SqlClient.SqlCommand(strDel, SqlConnection1)
cmdDel.ExecuteNonQuery()
'显示数据库
Dim SelectStr As String
SelectStr = "select distinct emp_id,fname,lname,job_id from employee "
Dim cmdSelect As New System.Data.SqlClient.SqlCommand()
cmdSelect = New SqlClient.SqlCommand(SelectStr, SqlConnection1)
cmdSelect.ExecuteNonQuery()
DataGrid1.EditItemIndex = -1
Dataview1.Table = ds.Tables("employee")
DataGrid1.DataSource = Dataview1
DataGrid1.DataBind()
SqlConnection1.Close()
Response.Redirect("webform1.aspx")
End Sub
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
' Dim DropDownList1 As New System.Web.UI.WebControls.DropDownList()
'DropDownList1 = e.Item.Cells(6).Controls(0)
'DropDownList1.DataBind()
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid1.SortCommand
Dataview1.Sort = e.SortExpression
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim emp_id, fname, lname, job_id As String
Dim tb As TextBox
DropDownList1 = e.Item.Cells(6).FindControl("DropDownList1")
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
emp_id = Trim(tb.Text)
tb = CType(e.Item.Cells(4).Controls(0), TextBox)
fname = Trim(tb.Text)
tb = CType(e.Item.Cells(5).Controls(0), TextBox)
lname = Trim(tb.Text)
job_id = Trim(DropDownList1.SelectedItem.Text)
'更新数据库
Dim Updatestr As String
Dim cmdUpdate As New System.Data.SqlClient.SqlCommand()
Updatestr = "Update employee set fname ='" & fname & "',lname='" & _
lname & "',job_id='" & job_id & "' where emp_id ='" & emp_id & "'"
SqlConnection1.Open()
cmdUpdate = New SqlClient.SqlCommand(Updatestr, SqlConnection1)
cmdUpdate.ExecuteNonQuery()
'显示数据库
Dim SelectStr As String
SelectStr = "select distinct emp_id,fname,lname,job_id from employee "
Dim cmdSelect As New System.Data.SqlClient.SqlCommand()
cmdSelect = New SqlClient.SqlCommand(SelectStr, SqlConnection1)
cmdSelect.ExecuteNonQuery()
DataGrid1.EditItemIndex = -1
Dataview1.Table = ds.Tables("employee")
DataGrid1.DataSource = Dataview1
DataGrid1.DataBind()
SqlConnection1.Close()
Response.Redirect("webform1.aspx")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Attributes.Add("onclick", "javascript:return confirm('click me');")
'Response.Redirect("http://www.google.com")
End Sub
编辑的时候不是我想要编辑的内容
...全文
相关推荐
Extjs grid 中文排序问题修正
Extjs grid 中文排序问题修正,其实很简单,请自己看源代码
蓝桥杯之数列排序问题python实现
蓝桥杯之数列排序问题python实现 题目 问题描述 给定一个长度为n的数列,将这个数列按从小到大的顺序排列。1<=n<=200 输入格式 第一行为一个整数n。 第二行包含n个整数,为待排序的数,每个整数的绝对值小于10000。 输出格式 输出一行,按从小到大的顺序输出排序后的数列。 样例输入 5 8 3 6 4 9 样例输出 3 4 6 8 9 代码 loop = int(input()) a = list(map(int,input().split())) a.sort() for i in a: if loop == 1: print('',end=str(i
使用蛮力法算法解决排序问题
蛮力法,也称穷举法,是一种最简单和直接的解决问题的办法,常常直接基于问题的描述,因此也是最容易应用的方法。虽然用蛮力法设计的算法其时间性能往往是低效的,但是,蛮力法基于计算机运算速度快的特性,在解决问题时采取一种“懒惰”策略,这种策略不经过(或者说经过很少)思考,把问题的所以情况或所有过程交给计算机去一一尝试,从中找出问题的解。所以,我们不应该忽略它的地位,此文档使用蛮力法分析排序问题。
排序问题C++MFC
排序问题C++MFC
MATLAB排序问题
分析MATLAB里面的矩阵排序问题,给出排序的相关要求,以及结果情况。要求效率要比较高。


