Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Textboxes when not in Edit mode

Reply
Thread Tools

Textboxes when not in Edit mode

 
 
Chip
Guest
Posts: n/a
 
      02-15-2004
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
 
Reply With Quote
 
 
 
 
dada
Guest
Posts: n/a
 
      02-17-2004
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
 
Reply With Quote
 
 
 
 
Chip
Guest
Posts: n/a
 
      02-17-2004
Thanks!

http://www.velocityreviews.com/forums/(E-Mail Removed) (dada) wrote in message news:<(E-Mail Removed). com>...
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formview dropdownlist won't populate in insert mode, but does in edit mode ??? jobs at webdos ASP .Net Web Controls 0 10-09-2006 03:38 PM
GridView control enters edit mode when I click Edit link twice Jaime Stuardo ASP .Net Web Controls 0 04-07-2006 12:47 AM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM
Would like to load a datagrid already in edit mode instead of having the user click the edit button Frank Kurka ASP .Net Datagrid Control 8 04-29-2005 09:33 AM



Advertisments