Textboxes when not in Edit mode

Discussion in 'ASP .Net Datagrid Control' started by Chip, Feb 15, 2004.

  1. Chip

    Chip Guest

    Hello,

    The scenario is this:

    A user needs to enter a value (for example, expenses) for a number of
    rows in a data grid (each row, for example, might be a customer the
    user is working with).

    I'd like to avoid having to have the user click edit, wait for the
    refresh, edit the item, click OK, wait for the refresh and repeat for
    each row. Rather, I'd like to have the user tab from text box to text
    box and enter the data (in the example, the expenses for each client).
    At the bottom of the screen would be an Update button.

    Question 1: How do I bind the data in a datagrid to the text box?
    I've tried template columns with a text box, but I cannot figure out
    how to bind the data.

    Question 2: How hard will the updating be?

    Thanks for any help!

    Chip
     
    Chip, Feb 15, 2004
    #1
    1. Advertising

  2. Chip

    dada Guest

    Maybe this will help:
    Top Questions about the DataGrid Web Server Control-Editing Multiple Rows At Once...

    ' Visual Basic
    Private Sub btnUpdate_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnUpdate.Click
    Dim i As Integer
    Dim dgi As DataGridItem
    Dim bookid As Integer
    Dim TextBoxTitle As TextBox
    Dim CheckBoxInStock As CheckBox
    Dim TextBoxPrice As TextBox
    Dim LabelBookId as Label

    For i = 0 To DataGrid1.Items.Count - 1
    dgi = DataGrid1.Items(i)
    LabelBookId = CType(dgi.Cells(0).Controls(1), Label)
    bookid = CType(LabelBookId.Text, Integer)
    TextBoxTitle = CType(dgi.FindControl("TextBoxTitle"), TextBox)
    CheckBoxInStock = _
    CType(dgi.FindControl("CheckBoxInstock"), CheckBox)
    TextBoxPrice = CType(dgi.FindControl("TextBoxPrice"), TextBox)
    Me.dcmdUpdateBooks.Parameters("@bookid").Value = bookid
    Me.dcmdUpdateBooks.Parameters("@Title").Value = TextBoxTitle.Text
    Me.dcmdUpdateBooks.Parameters("@instock").Value = _
    CheckBoxInStock.Checked
    Me.dcmdUpdateBooks.Parameters("@Price").Value = TextBoxPrice.Text
    Me.SqlConnection1.Open()
    Me.dcmdUpdateBooks.ExecuteNonQuery()
    Me.SqlConnection1.Close()
    Next
    End Sub
     
    dada, Feb 17, 2004
    #2
    1. Advertising

  3. Chip

    Chip Guest

    Thanks!

    (dada) wrote in message news:<>...
    > Maybe this will help:
    > Top Questions about the DataGrid Web Server Control-Editing Multiple Rows At Once...
    >
    > ' Visual Basic
    > Private Sub btnUpdate_Click(ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) Handles btnUpdate.Click
    > Dim i As Integer
    > Dim dgi As DataGridItem
    > Dim bookid As Integer
    > Dim TextBoxTitle As TextBox
    > Dim CheckBoxInStock As CheckBox
    > Dim TextBoxPrice As TextBox
    > Dim LabelBookId as Label
    >
    > For i = 0 To DataGrid1.Items.Count - 1
    > dgi = DataGrid1.Items(i)
    > LabelBookId = CType(dgi.Cells(0).Controls(1), Label)
    > bookid = CType(LabelBookId.Text, Integer)
    > TextBoxTitle = CType(dgi.FindControl("TextBoxTitle"), TextBox)
    > CheckBoxInStock = _
    > CType(dgi.FindControl("CheckBoxInstock"), CheckBox)
    > TextBoxPrice = CType(dgi.FindControl("TextBoxPrice"), TextBox)
    > Me.dcmdUpdateBooks.Parameters("@bookid").Value = bookid
    > Me.dcmdUpdateBooks.Parameters("@Title").Value = TextBoxTitle.Text
    > Me.dcmdUpdateBooks.Parameters("@instock").Value = _
    > CheckBoxInStock.Checked
    > Me.dcmdUpdateBooks.Parameters("@Price").Value = TextBoxPrice.Text
    > Me.SqlConnection1.Open()
    > Me.dcmdUpdateBooks.ExecuteNonQuery()
    > Me.SqlConnection1.Close()
    > Next
    > End Sub
     
    Chip, Feb 17, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    550
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    523
    Edward Loper
    Aug 7, 2007
  3. Frank Kurka
    Replies:
    8
    Views:
    343
  4. Jaime Stuardo

    GridView control enters edit mode when I click Edit link twice

    Jaime Stuardo, Apr 7, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    453
    Jaime Stuardo
    Apr 7, 2006
  5. jobs at webdos
    Replies:
    0
    Views:
    525
    jobs at webdos
    Oct 9, 2006
Loading...

Share This Page