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

get value of each row in textbox column

2 Answers 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
shervinrv
Top achievements
Rank 1
shervinrv asked on 23 Sep 2014, 05:06 AM
Hello.
Excuse me if my english is not well.
i have a textbox column in radgrid.
<telerik:GridTemplateColumn  SortExpression="score" HeaderText="score" HeaderButtonType="TextButton"
                    DataField="score" UniqueName="score" ReadOnly="true">
                       <ItemTemplate>
                           <telerik:RadTextBox runat="server">
 
                           </telerik:RadTextBox>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>

and a button . 
how can i get value of each textbox by clicking button ?
for example row with id=1 >> textbox=15
actually i'm looking for bulk data submit.in edit mode i can submit values row by row and it's time consuming.
if there is any other option please tell me.
thank you

2 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Sep 2014, 08:08 AM
Hi,

Please write below code in button click event.
foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
{
    RadTextBox txtscore = item.FindControl("txtscore") as RadTextBox;
    string id = item.GetDataKeyValue("id").ToString();
    // Access id and textbox value here
}

Also add datakey in mastertablerview tag and add ID in textbox

<MasterTableView DataKeyNames="id">
.........
.........
 
<telerik:GridTemplateColumn  SortExpression="score" HeaderText="score" HeaderButtonType="TextButton"
        DataField="score" UniqueName="score" ReadOnly="true">
    <ItemTemplate>
            <telerik:RadTextBox ID="txtscore" runat="server">
 
            </telerik:RadTextBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Let me know if any concern.

Thanks,
Jayesh Goyani
0
shervinrv
Top achievements
Rank 1
answered on 23 Sep 2014, 08:31 AM
Thank you Jayesh Goyani.
It works
Tags
Grid
Asked by
shervinrv
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
shervinrv
Top achievements
Rank 1
Share this question
or