1
votes

I have a text box and button inside of my ASPXGridview, DetailRow view. So when it's expanded I need to type text and click button and on server side to get value from the textbox.

Here is my code. The problem is somewhere on postback I'm loosing text value. So text box is empty

 protected void Button1_Click(object sender, EventArgs e)
    {

        ASPxGridView grid = EmailGridView;

        for (int i = 0; i < grid.VisibleRowCount; i++)
        {
            var txtDescription = (ASPxMemo)grid.FindDetailRowTemplateControl(i, "txtDescription");

            if(txtDescription != null)
            {
                var text = txtDescription.Text;
            }
        }
    }

<dxwgv:ASPxGridView ID="EmailGridView" KeyFieldName="ThreadId" runat="server" AutoGenerateColumns="False"
OnHtmlRowCreated="EmailGridView_HtmlRowCreated" SettingsDetail-AllowOnlyOneMasterRowExpanded="true"
SettingsBehavior-ConfirmDelete="true" OnHtmlRowPrepared="EmailGridView_HtmlRowPrepared"
OnRowDeleted="EmailGridView_RowDeleted">
<SettingsBehavior ConfirmDelete="True" />
<Columns>
    <dxwgv:GridViewDataTextColumn Caption="ID" FieldName="Id" VisibleIndex="0">
    </dxwgv:GridViewDataTextColumn>

    <dxwgv:GridViewCommandColumn VisibleIndex="5" Caption=" ">
        <DeleteButton Visible="True">
        </DeleteButton>
    </dxwgv:GridViewCommandColumn>
</Columns>
<SettingsDetail ShowDetailRow="true" />
<SettingsBehavior ConfirmDelete="True" />
<SettingsDetail AllowOnlyOneMasterRowExpanded="True" ShowDetailRow="True" />
<Templates>
    <DetailRow>
        <dxwgv:ASPxGridView ID="EmailSubGridView" Width="750px" OnBeforePerformDataSelect="EmailSubGridView_BeforePerformDataSelect"
            runat="server" AutoGenerateColumns="False" 
            onhtmlrowcreated="EmailSubGridView_HtmlRowCreated">
            <Columns>
                <dxwgv:GridViewDataTextColumn Caption="MessFrom" FieldName="MessFrom">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="Message" FieldName="Message">
                </dxwgv:GridViewDataTextColumn>
                <dxwgv:GridViewDataTextColumn Caption="SendDtm" FieldName="SendDtm">
                </dxwgv:GridViewDataTextColumn>
            </Columns>
            <StylesEditors>
                <ProgressBar Height="25px">
                </ProgressBar>
            </StylesEditors>
        </dxwgv:ASPxGridView>


            <dx:ASPxMemo ID="txtDescription" runat="server" Width="170px" Height="71px"></dx:ASPxMemo>

        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Reply" />
    </DetailRow>
</Templates>

2
where do you bind data to GridView ? - emre nevayeshirazi

2 Answers

0
votes

Conny,

The ASPxGridView has callbacks built into it so I recommend using that approach as it's easier and it gives you a better user experience. The find method you're using requires the visiblerowindex.

Take a look a this code central example to see how to get data from the server:

How to bind the detail GridView to data based on the end-user input

0
votes

If you want these process when you are expanding your ASPxGridview, you should use DetailRowExpandedChanged event.

This event works when you expand or collapse your ASPxGridview.

Mehul's example is very good actually for this situation. After that, if you still have a problem, you can ask your question in Devexpress Support. They are really helpful and quick.