我想实现这样的效果选checkbox然后按编辑按钮然后所选行进入编辑状态!

解决方案 »

  1.   

    是在DataGrid里面实现吗?用模板列可以实现。
      

  2.   

    用摸板列
    <asp:DataGrid id="dgInfo" style="Z-INDEX: 101; LEFT: 198px; POSITION: absolute; TOP: 49px" runat="server" AutoGenerateColumns="False">
    <ItemStyle Font-Size="10pt" Font-Names="Times New Roman" ForeColor="#0000C0"></ItemStyle>
    <HeaderStyle Font-Size="10pt" Font-Names="Times New Roman" Font-Bold="True" ForeColor="White" BackColor="Navy"></HeaderStyle>
    <Columns>
    <asp:BoundColumn DataField="id" ReadOnly="True" HeaderText="ID"></asp:BoundColumn>
    <asp:BoundColumn DataField="utype" ReadOnly="True" HeaderText="UserType"></asp:BoundColumn>
    <asp:BoundColumn DataField="command" ReadOnly="True" HeaderText="Command">
    <HeaderStyle Width="120px"></HeaderStyle>
    </asp:BoundColumn>
    <asp:TemplateColumn HeaderText="ProjectID">
    <ItemTemplate>
    <asp:TextBox ID="txtQuantity" Runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"quantity")%>' Width="60px">
    </asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
    后台代码:
    Sub updateQuantity(ByVal id As Integer, ByVal quantity As Integer)        Dim myCommand As SqlDataAdapter = New SqlDataAdapter("usp_UpdataQuantity", myConnection)
            myCommand.SelectCommand.CommandType = CommandType.StoredProcedure        myCommand.SelectCommand.Parameters.Add(New SqlParameter("@projectid", SqlDbType.Int, 4))
            myCommand.SelectCommand.Parameters("@projectid").Value = id        myCommand.SelectCommand.Parameters.Add(New SqlParameter("@quantity", SqlDbType.Int, 4))
            myCommand.SelectCommand.Parameters("@quantity").Value = quantity        myConnection.Open()
            myCommand.SelectCommand.ExecuteNonQuery()
            myConnection.Close()
        End Sub    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
            Dim i As Integer        '循环遍历textbox里面的值
            For i = 0 To dgInfo.Items.Count - 1            Dim id As Integer = dgInfo.Items(i).Cells(0).Text
                Dim quantityid As TextBox = dgInfo.Items(i).FindControl("txtQuantity")
                Dim quantity As Integer = quantityid.Text            If quantity <> 0 Then
                    updateQuantity(id, quantity)
                End If
            Next
            BindData()
        End Sub