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

Getting Textbox value

8 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Karthi Keyan
Top achievements
Rank 1
Karthi Keyan asked on 15 Oct 2009, 11:50 AM
Hi,
        I am having textbox inside my rad gridview and having one button.once if i give some value to that textbox and click the button.
        how can i get the textbox value.Since i am having that textbox in data template i cant get it.
        will anyone provide with sample code.

8 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 15 Oct 2009, 12:18 PM
Hi Karthi Keyan,

If you know which cell you are operating on, you can use the ChildrenOfType<T> method to find the TextBox that is inside it like this:

TextBox txt = cell.ChildrenOfType<TextBox>[0].

Please, send us a sample project if this does not help and explain the exact behavior that you would like to achieve. We will try to come up with something.

All the best,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kaustubh Wadi
Top achievements
Rank 1
answered on 12 Apr 2010, 07:58 AM
Hi all,
I have the same requirement, just difference is I have rad combo box insteed of text box. And on button click I have the selected item value of rad combobox in a variable. How can I do that? Can anyone tell me?

Thanks,
Kaustubh.
0
Vlad
Telerik team
answered on 12 Apr 2010, 10:32 AM
Hello,

You can use exactly the same approach - just change the generic argument to desired type.

Greetings,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kaustubh Wadi
Top achievements
Rank 1
answered on 12 Apr 2010, 10:42 AM
Thanks Vlad for your response.
    I have tried, by changing the generic argument. But its not working.

Thanks,
Kaustubh.
0
Vlad
Telerik team
answered on 12 Apr 2010, 10:50 AM
Hello,

Can you post your XAML (how the combo is declared) and the code that you have tried?

Kind regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kaustubh Wadi
Top achievements
Rank 1
answered on 12 Apr 2010, 10:53 AM

Hi,

Here I am giving the snippet what I have dont in xaml file for your understanding. If user selects sample2 item from combo box, then I have to retrieve that value and store it into sharepoint list.


<
grid:RadGridView x:Name="grid" Margin="100,100,100,100" RowIndicatorVisibility="Collapsed" IsReadOnly="True" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserResizeColumns="False" Width="520" Height="270" >

 

 

    <grid:RadGridView.Columns>

 

 

        <grid:GridViewDataColumn x:Name="gaugeColumn"  Header="Header1"  HeaderTextAlignment="Center"  Width="150" DataMemberBinding="{Binding ID}" TextAlignment="Center"/>

 

 

 

 

 

<grid:GridViewDataColumn x:Name="measureColumn" HeaderText="Header2" HeaderTextAlignment="Center" Width="200">

 

 


<
grid:GridViewDataColumn.CellTemplate>

 

 

    <DataTemplate>

 

 

        <telerikInput:RadComboBox Name="cbMeasures" SelectedIndex="0">

 

 

            <telerikInput:RadComboBoxItem Content="Sample1" />

 

 

            <telerikInput:RadComboBoxItem Content="Sample2" />

 

 

            <telerikInput:RadComboBoxItem Content="Sample3" />

 

 

            <telerikInput:RadComboBoxItem Content="Sample4" />

 

 

        </telerikInput:RadComboBox>

 

 

    </DataTemplate>

 

 

</grid:GridViewDataColumn.CellTemplate>

 

 

 

</grid:GridViewDataColumn>

 

 

<grid:GridViewDataColumn HeaderText="Header3" HeaderTextAlignment="Center" Width="150">

 

 

        <grid:GridViewDataColumn.CellTemplate>

 

 

            <DataTemplate>

 

 

                <telerikInput:RadComboBox Name="cbDisplay" SelectedIndex="0" >

 

 

                    <telerikInput:RadComboBoxItem Content="Yes" />

 

 

                    <telerikInput:RadComboBoxItem Content="No" />

 

 

                </telerikInput:RadComboBox>

 

 

        </DataTemplate>

 

 

</grid:GridViewDataColumn.CellTemplate>

 

 

</grid:GridViewDataColumn>

 

 

</grid:RadGridView.Columns>

 

 

 

</grid:RadGridView>

 

0
Vlad
Telerik team
answered on 12 Apr 2010, 10:58 AM
Hello,

Why not use SelectionChanged event of the combo directly?

Kind regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kaustubh Wadi
Top achievements
Rank 1
answered on 12 Apr 2010, 11:00 AM
In codebehind file:


private

void saveButton_Click(object sender, RoutedEventArgs e)

 

{


GridViewCell

secondCell = (GridViewCell)row.Items[1];

 

RadComboBox

txt = secondCell.ChildrenOfType<RadComboBox>[0];

}

At <RadComboBox>[0], it is giving error "RadCombobox is a 'type' but is used as 'variable' ".
also what this " 0 " indicating? Can you explain for me?

Thanks,
Kaustubh

 

Tags
GridView
Asked by
Karthi Keyan
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Kaustubh Wadi
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or