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

Rad Grid in place editing

1 Answer 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Serigne ndiaye
Top achievements
Rank 1
Serigne ndiaye asked on 22 Sep 2009, 01:42 PM
How can I access the text inside txtProgram from code behind. I am able to use findcontrol to find the ID of the text box, but I cannot access the Text property of txtProgram to be able to process the data.
<radg:radgrid ID="grdProgram" runat="server"
        onneeddatasource="grdProgram_NeedDataSource"
        onitemdatabound="grdProgram_ItemDataBound"
        onitemcommand="grdProgram_ItemCommand">
    <MasterTableView EnableNoRecordsTemplate="True" AutoGenerateColumns="false" DataKeyNames="ProID">
        <Columns>
      
         <radG:GridTemplateColumn HeaderText="Program">
        <ItemStyle Width="80%" VerticalAlign="top" />
        <HeaderStyle Width="80%" />
        <ItemTemplate>
        <div><%#Eval("Pog")%> </div>
           Default Url: <br />
            <br />
    <asp:TextBox ID="txtProgram" runat="server"   Width="70%">Some Text From user</asp:TextBox>
        </ItemTemplate>
    </radG:GridTemplateColumn>
           <radG:GridButtonColumn ButtonType="linkButton"     Text="Save Custom Link" HeaderText="Edit" UniqueName="edit" CommandName="EDITME">
                    <ItemStyle HorizontalAlign="center" />
           </radG:GridButtonColumn>
        </Columns>
        <NoRecordsTemplate>
            No Current Programs</NoRecordsTemplate>
    </MasterTableView>
</radg:radgrid>

1 Answer, 1 is accepted

Sort by
0
Todd Anglin
Top achievements
Rank 2
answered on 23 Sep 2009, 03:47 AM
Hello Serigne-

What code are you using today to access the textbox? In general, accessing a control in a RadGrid cell looks something like this:

var myTxtBox = myGridDataItem["columnName"].Controls[0] as TextBox;
var strText = myTxtBox.Text;

You access the control in the cell that you're targeting, cast it to the correct object type, and then you should have full access to the properties. If you want access to databound values, you need to do this in the OnItemDataBound (or later) event. More details here:


Hope that helps.
-Todd
Tags
Grid
Asked by
Serigne ndiaye
Top achievements
Rank 1
Answers by
Todd Anglin
Top achievements
Rank 2
Share this question
or