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"
            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>
  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.
    -Todd
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top