Rad Grid in place editing

2 posts, 0 answers
  1. Serigne ndiaye
    Serigne ndiaye avatar
    3 posts
    Member since:
    Aug 2009

    Posted 22 Sep 2009 Link to this post

    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"
        <MasterTableView EnableNoRecordsTemplate="True" AutoGenerateColumns="false" DataKeyNames="ProID">
             <radG:GridTemplateColumn HeaderText="Program">
            <ItemStyle Width="80%" VerticalAlign="top" />
            <HeaderStyle Width="80%" />
            <div><%#Eval("Pog")%> </div>
               Default Url: <br />
                <br />
        <asp:TextBox ID="txtProgram" runat="server"   Width="70%">Some Text From user</asp:TextBox>
               <radG:GridButtonColumn ButtonType="linkButton"     Text="Save Custom Link" HeaderText="Edit" UniqueName="edit" CommandName="EDITME">
                        <ItemStyle HorizontalAlign="center" />
                No Current Programs</NoRecordsTemplate>
  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 22 Sep 2009 Link to this post

    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.
Back to Top