日期:2014-05-20  浏览次数:20491 次

用GRIDVIEW显示查询结果,然后点编辑另起一页进行编辑?求方法.
小弟用VS2005,ASP2.0和VB.NET进行编写.
现在碰到个问题,我查询代码自己写的,显示在GRIDVIEW里面,然后在GRIDVIEW里面添加编辑按钮,然后联接到另外一个页面把选中的内容详细的列出来进行编辑,求方法.
我的代码是:
查询:
Protected   Sub   Button1_Click(ByVal   sender   As   Object,   ByVal   e   As   System.EventArgs)   Handles   Button1.Click
                Dim   myConnectionString   As   String
                myConnectionString   =   "server=localhost;database=NBDC;uid=****;pwd=****; "
                Dim   myConnection   As   New   SqlConnection(myConnectionString)
                Dim   mySelect   As   String   =   "SELECT   *   FROM   Repository   WHERE   Name   LIKE   '% "   +   TextBox3.Text   +   "% '   AND   Operator   LIKE   '% "   +   DropDownList1.Text   +   "% '   AND   Type   LIKE   '% "   +   DropDownList2.Text   +   "% '   AND   Server   LIKE   '% "   +   DropDownList3.Text   +   "% '   AND   Detail   LIKE   '% "   +   TextBox4.Text   +   "% '   AND   Keyword   LIKE   '% "   +   TextBox6.Text   +   "% ' "
                Dim   myCommand   As   New   SqlCommand(mySelect)
                Dim   adapter   As   SqlDataAdapter   =   New   SqlDataAdapter(mySelect,   myConnection)
                myCommand.Connection   =   myConnection
                myConnection.Open()
                Dim   ds   As   New   DataSet
                adapter.Fill(ds)
                GridView1.DataSource   =   ds
                GridView1.DataBind()
                myCommand.Connection.Close()
        End   Sub
显示:
<asp:GridView   ID= "GridView1 "   runat= "server "   AllowPaging= "True "   Width= "780px "   Font-Size= "Small "   ForeColor= "Black "     AutoGenerateColumns= "False "   DataKeyNames= "RepositoryID "   AutoGenerateDeleteButton= "True "   AutoGenerateEditButton= "True "   EnableSortingAndPagingCallbacks= "True "   PageSize= "8 ">
                                <Columns>
        <asp:BoundField   DataField= "Name "   HeaderText= "名称 "> </asp:BoundField>
<asp:BoundField   DataField= "Operator "   HeaderText= "操作者 "> </asp:BoundField>
<asp:BoundField   DataField= "Type "   HeaderText= "类型 "> </asp:BoundField>
<asp:BoundField   DataField= "Datetime "   HeaderText= "时间 "> </asp:BoundField>