This is a migrated thread and some comments may be shown as answers.

[Solved] Loop thru a GridTableView

5 Answers 382 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 29 Apr 2008, 07:12 PM
Hi all,

I have a GridTableView which shows all the rows for an associated MasterTableView.  I also made some columns in the GridTable as editable.  In fact, i have this setup as full-screen editing.  So the user can change 20 rows at once.  I created an ASP:LinkButton outside of the radgrid.  When clicked, I want to loop thru my GridTableView so that I can update my database.  I want to do something like:

Protected

Sub lbSaveProjections_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbSaveProjections.Click

Dim gi As Telerik.Web.UI.GridDataItem

For Each gi In IllustrationProjections.GridTableView.

UpdateMyDataBase()

Next

End Sub


This code is invalid though.  I do not know how to do this.  IllustrationProjections is the name of myGridTableView.

Can someone help?

Thanks,
Bob

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Apr 2008, 05:05 AM
Hi Bob,

Try the following code snippet to loop through the GridEditableItems in RadGrid on clicking the LinkButton.

CS:
  protected void LinkButton2_Click(object sender, EventArgs e)  
    {  
        foreach (GridEditableItem edititem in RadGrid1.MasterTableView.GetItems(GridItemType.EditItem))  
        {   
          
        }  
    } 

Go through the following help article to get details about BacthUpdate in RadGrid.
Performing batch updates

Thanks
Princy.
0
Bob
Top achievements
Rank 1
answered on 30 Apr 2008, 12:28 PM
Princy,

I want to do this for a GridTableView not a MasterTableView.  Your example seems to be for a MasterTableView only.  Also, here is my html for my editable items:

<

telerik:GridTemplateColumn UniqueName="AccountValueAmt" HeaderText="Account Value" ItemStyle-Width="70px">

<ItemTemplate>

<telerik:RadNumericTextBox ID="tbAccountValueAmt" runat="server" Text='<%# Eval("AccountValueAmt") %>' TabIndex="1" Width="70px"></telerik:RadNumericTextBox>

</ItemTemplate>

</telerik:GridTemplateColumn>


So I want to loop thru all items in my GridTableView and retrieve the value of the radNumericTextBox tbAccountValue so that I can update my database.  I cannot figure out the code to getthis value.

Thanks,
Bob
0
Shinu
Top achievements
Rank 2
answered on 30 Apr 2008, 01:19 PM
Hi Bob,

Try the following code snippet to access a RadNumericTextBox present in a Detail table.

CS:
 protected void LinkButton2_Click(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.Items) 
        { 
            if (item.OwnerTableView.Name == "Detail") 
            { 
                RadNumericTextBox radnumtxtbx = (RadNumericTextBox)item["AccountValueAmt"].FindControl("tbAccountValueAmt"); 
            } 
        } 
    } 


Thanks
Shinu.
0
Bob
Top achievements
Rank 1
answered on 30 Apr 2008, 05:05 PM
Shinu,

Thanks.  That worked.

I have another question for you.  Still in the GridTableView, I have a link button that deletes the row from the SQL table.  The delete works fine.  But how do I force my Protected Sub rgIllustration_DetailTableDataBind subroutine to execute again so that my deleted row disappears?

Thanks,
Bob
0
Yavor
Telerik team
answered on 01 May 2008, 07:31 AM
Hi Bob,

You can call the Rebind() method for the control or any detail table, to make sure that it is refreshed.

Kind regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bob
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Yavor
Telerik team
Share this question
or