-1

I'm working on a DevExpress Gridview and I want to get the data of the selected row (only one row can be selected at the time). I'm working on the Server-Side and I'm using FocusedRowChanged function.

EDIT: The FocusedRowChanged fire but nothing happen and the textboxes do not change value

protected void dxgrDepartement_FocusedRowChanged(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterClientScriptBlock(GetType(), "FetchData", "<script                          language='javascript'>FetchData('4654654646')</script>");
            txtDescription.Text = "patate";
            //txtComments.Text = dxgrDepartement.GetRowValues(dxgrDepartement.FocusedRowIndex, "IdDepartment").ToString();
        }

And the "FetchData :

        function FetchData(text) {
        //ClearField();
        document.getElementById("<%= txtDescription.ClientID %>").value = text.toString();
    }
Filip
  • 3,257
  • 2
  • 22
  • 38
GmodCake
  • 427
  • 3
  • 11
  • 24

3 Answers3

1

Use:

gridView.GetRowValues(gridView.FocusedRowIndex, columnFieldName1, columnFieldName2, ..., columnFieldNameN)

Method ASPxGridView.GetRowValues
Property ASPxGridView.FocusedRowIndex

Filip
  • 3,257
  • 2
  • 22
  • 38
1

grid.EnableCallback = false; solved my problems!

Cezar
  • 55,636
  • 19
  • 86
  • 87
GmodCake
  • 427
  • 3
  • 11
  • 24
1

BTW - Changing the callbacks property made no difference for us. We needed callbacks for other functionality so couldn't turn this off anyway.

The GetRowValues method did not work either.

This is a technique described on DevExpress' web site and it worked for us as long as we didnt use DevExpress' controls (ASPxDateEdit, ASPxTextBox):

ASPX page:

    <dxwgv:GridViewDataTextColumn Caption="Dist. %" FieldName="DistributionPerc" VisibleIndex="3"
        Width="50px">
        <DataItemTemplate>
            <asp:TextBox ID="txtDistPerc" runat="server" Text='<%# Eval("DistributionPercent") %>'
                Width="50px" />
        </DataItemTemplate>
    </dxwgv:GridViewDataTextColumn>

Code behind:

for (int i = 0; i < grdHistory.VisibleRowCount; i++)
{
    TextBox textbox = grdHistory.FindRowCellTemplateControl(i, grdHistory.Columns["DistributionPerc"] as GridViewDataColumn, "txtDistPerc") as TextBox;
    var anything = textbox.Text;
}