From: DavidC on
Given this solution, does the user have to click the edit button on every row?
--
David


"Mr. Arnold" wrote:

> DavidC wrote:
> > I tried the SelectedIndexChanged event but I do not want to have to "select"
> > the row before doing anything. I just want the user to enter data into the
> > textbox, update the underlying database record (based on the DataKey value)
> > and then move down to the next row (via user tabbing to it) and do the same
> > thing with multiple rows. Picture a list of rows where each row is updated
> > as data is entered in the textbox. Does this change anything in your
> > recommendation? I am not sure the ItemCommand fires each time the cursor
> > moves down to the new row. Thanks.
>
> Then you need a Edit Template with a asp:Edit button with property
> Command="Edit". The Edit template can have this asp:textbox as a control.
>
> Then you're going to need a Update Template with an asp:Button
> Text="Update" Command="Update" and an asp:Button Text="Cancel"
> Command="Cancel".
>
> And it's still on the GrivView_ItemCommand(object sender, EventArgs e)
> like the example previously provided to you but a 3rd party
> <telrick:RadListView> control.
>
> It's the same thing, which is off of e.Item as the item in the grid you
> are working on.
>
> protected void RadListView_ItemCommand(object sender,
> RadListViewCommandEventArgs e)
> {
> if (e.CommandName == "Update")
> {
> var groupID =
> (int)((RadListViewDataItem)e.ListViewItem).GetDataKeyValue("GroupID");
>
> //rest of the code -- You can run off to the database and do it.
> }
> }
> .
>
From: Mr. Arnold on
DavidC wrote:
> Given this solution, does the user have to click the edit button on every row?

Yeah, if the user wants to edit the textbox in the templete.

The edit button is going to be in the template for every row on the grid.
From: DavidC on
Below is what I am doing on a different web page that updates any row in an
ItemTemplate when the user checks a checkbox in that row and it works
perfectly. That page uses a ListView but the concept should be the same. The
user does not need to click on an edit button, it just grabs the key and runs
an update. I am hoping this helps you show me how to do the same thing in a
GridView on a TextChanged event. Thanks.

Sub Check_Clicked(ByVal sender As Object, ByVal e As EventArgs)
' Gets the CheckBox object that fired the event.
Dim chkBox As CheckBox = CType(sender, CheckBox)

' Gets the item that contains the CheckBox object.
Dim item As ListViewDataItem = CType(chkBox.Parent, ListViewDataItem)
Dim intTransID As Int32 =
Convert.ToInt32(lvIncExpTrans.DataKeys(item.DataItemIndex).Value)

If VendorClass.ChangeIncExpTransPick(intTransID, chkBox.Checked) =
False Then
Dim tb As TextBox = Page.Master.FindControl("txtMsg")
' Replace ListView1 with ID of your ListView Control
'tb.Text = "TransID sent = " &
lvIncExpTrans.DataKeys(item.DataItemIndex).Value
tb.Text = "The update to the checkbox failed."
End If
lvIncExpTrans.DataBind()
End Sub

--
David


"Mr. Arnold" wrote:

> DavidC wrote:
> > Given this solution, does the user have to click the edit button on every row?
>
> Yeah, if the user wants to edit the textbox in the templete.
>
> The edit button is going to be in the template for every row on the grid.
> .
>
From: DavidC on
FYI, I solved it by putting the datakey value into a hidden column on the row
and used the code below. Now I just need to use javascript to loop through
the GridView rows to total the values the user enters into each TextBox. I
have that code in my TextChanged event (see previous post) and it works great
except that using FindControl screws up the tab order and puts the cursor in
the footer. Have you found any code examples that loop through a GridView
(table) and grabs values of specific column controls (td's)? Thanks.

Dim lbl As Label = CType(sender.parent.FindControl("LblTempID"),
Label)
Dim intTempID As Int32 = Convert.ToInt32(lbl.Text)


--
David


"Mr. Arnold" wrote:

> DavidC wrote:
> > Given this solution, does the user have to click the edit button on every row?
>
> Yeah, if the user wants to edit the textbox in the templete.
>
> The edit button is going to be in the template for every row on the grid.
> .
>
From: Mr. Arnold on
DavidC wrote:
> FYI, I solved it by putting the datakey value into a hidden column on the row
> and used the code below. Now I just need to use javascript to loop through
> the GridView rows to total the values the user enters into each TextBox. I
> have that code in my TextChanged event (see previous post) and it works great
> except that using FindControl screws up the tab order and puts the cursor in
> the footer. Have you found any code examples that loop through a GridView
> (table) and grabs values of specific column controls (td's)? Thanks.
>
> Dim lbl As Label = CType(sender.parent.FindControl("LblTempID"),
> Label)
> Dim intTempID As Int32 = Convert.ToInt32(lbl.Text)
>
>

No, I have not had to loop through TD's in javascript. Where I would
might try to catch it is on ItemBound event off of e.item again and
FindControl that would be the item the user was working on at the time.