A: 

Am I right in my assumption that the button is residing in the same DetailRowTemplate container? Anyway, it is necessary to access the proper instance of the detail GridView object. To do this, set the grid's ClientInstanceName property to a dynamic value. This should allow you to access the proper grid instance and fetch selected row values. A sample code is available at:

http://www.devexpress.com/Support/Center/ViewIssue.aspx?issueid=Q90007

DevExpress Team
Button is not in DetailRowTemplate, it's outside of the grid.
mehmetserif
If so, there can be many detail grids. How do you decide which grid values should be fetched?
DevExpress Team
There is only one detail grid, and the button is outside of all grids, it's in an html table. Spesific ClientInstanceName is not enough?
mehmetserif
Hmm, I think that I do not quite understand you. Are you using two grids separately? Or do you have a detail grid, residing in the DetailRowTemplate container of the master grid, as shown in DevExpress demos? If the latter case, the number of detail grids at the moment equals the number of visible expanded master rows. That is why I suggested you use the approach with a dynamic ClientInstanceName.
DevExpress Team
No, i don't use them separately, detail grid is in DetailRowTemplate but what i want to know is that, is it important to have the button inside of DetailRowTemplate?Because if it's outside of the DetailRowTemplate "Container.VisibleIndex" doesn't work. Also in my case there will be only one master grid and detail grid.
mehmetserif
If there is only a single detail grid at a time, your code should work fine. It is not important to have a button inside a template container. So far, I have only two ideas:1) make certain that the button's AutoPostBack property is set to false;2) make certain that there are selected rows when this button is clicked.Also, I do not see a column whose field name is PrmDetailName. But you are requesting its value in the script.
DevExpress Team
Yes, there is a column whose field name is PrmDetailName. Its VisibleIndex is 2. If the button outside of the DetailRowTemplate, how can i set the VisibleIndex of the DetailGrid. Because on the ClientSideEvents of a AspxButton, Container.VisibleIndex doesn't work.
mehmetserif
If the button is outside of the TemplateContainer and there is only a single master row expanded (this is very important) and there are selected rows in this grid, your code should work. I do not see a reason for it to do not work.
DevExpress Team
Please let me know how your grids are bound to data source. I.e. did you set DataSourceID property of both grids, or you are setting the DataSource property in runtime and than call DataBind method? If the latter case, please post your code here (I wonder, when you set the DataSource property and when you call DataBind).
DevExpress Team
I wrote how i set the DataSource below.
mehmetserif
A: 

I'm setting the DataSource at Runtime but i do not call DataBind method, because it makes BeforePerformDataSelect of the Detail Grid to perform more than one.

This code set the master grids datasource and bind it:

protected void gv_Answers_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) {

        ConfPrmMTempCollection _ConfPrmMTempCollection = new ConfPrmMTempCollection();
        masterKey = e.Parameters;

        if (masterKey != "")
        {
            man.Add(new SqlOperatorEquality("MAND_CONF_PRM_M_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));
            gv_Answers.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmMTempCollection),man);
            gv_Answers.DataBind();

            man.Clear();

        }
    }

And this code is for setting the datasource of the detail grid:

protected void gv_ParameterTempD_BeforePerformDataSelect(object sender, EventArgs e) {

        ASPxGridView detailGrid = sender as ASPxGridView;

        masterKey = detailGrid.GetMasterRowKeyValue().ToString();
        man.Add(new SqlOperatorEquality("MAND_CONF_PRM_D_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));

        detailGrid.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmDTempCollection),man);
    }
mehmetserif
A: 

I see that you set the master grid's DataSource in the CustomCallback event handler. Try to cache the masterKey value in a Session variable and set the grid's DataSource not only in the CustomCallback event handler but also in the Page_Init method:

protected void Page_Init(object sender, EventArgs e) {
    if(Session["masterKey"] == null)
      return;
    ConfPrmMTempCollection _ConfPrmMTempCollection = new ConfPrmMTempCollection();

            masterKey = Session["masterKey"].ToString();

            if (masterKey != "")
            {
                man.Add(new SqlOperatorEquality("MAND_CONF_PRM_M_TEMP.PARAMETER_M_TEMP_ID", Convert.ToInt32(masterKey)));
                gv_Answers.DataSource = gc.LoadCollectionFromCollType(typeof(ConfPrmMTempCollection),man);
                man.Clear();
            }

    }


    protected void Page_Load(object sender, EventArgs e) {
                gv_Answers.DataBind();
    }

Does this help?

DevExpress Team
But that grid shows up in a PopupControl and there is one another grid to shows that PopupControl. So i can't load this grid on PageInit. Because data is loaded by the value passed from first grid.
mehmetserif
The value from the master grid can be saved in a Session variable. When the next request is processed, you will be able to fetch it from the Session and fill the grid with data based on this parameter. I've posted a code before showing how this can be done. Please try this approach, it should work.
DevExpress Team
This code loads the grid at page load. But master-detail grid doesn't show up at page load. So i can save the value in a Session variable, but doesn't help to me. All i want to do is that get the field value of a selected row. But i always get an empty variable, "GetSelectedFieldValues" doesn't seem to be working in my case.
mehmetserif
I feel as I do not quite understand how the grid works in your application. Could you please describe your task in details? I will try to recreate the problem on my machine and let you know the solution.
DevExpress Team
Ok, there is one grid on a page loaded with datas and when you double click on a row, PopupControl shows up. There is a Master-Detail grid on that PopupControl, loads by the value passed from the grid which is on the page. What i want to do is that in the detail grid user will select rows and click add to list. So everything works really fine until "Add to List" case. I can't get the field values on a selected row of the detail grid. Maybe it's not a confusing task but i couldn't really do it. Thanks for your help.
mehmetserif
Did you have time to create the problem on your machine?
mehmetserif
Not yet :(. I hope to recreate your configuration locally by the end of the week end. BTW, which version are you using?
DevExpress Team
Ok, this is going to be very important task for me and i'm using 9.2v of DevExpress.
mehmetserif
A: 

I have created a sample project based on your description and it works fine. It is available to download from:

http://www.devexpress.com/Support/Center/ViewIssue.aspx?issueid=Q220495

DevExpress Team
I can't run the project because my devexpress version is 9.2 but you used 10.1 so i got an assembly error and .net version you used is 2.0, mine is .net 3.5. What can i do to debug your project?
mehmetserif
You should use the ProjectConverter tool (Start-->Developer Express v2009 vol 2-->Components-->Tools) shipped within the Suite to upgrade my project to your DXperience version. As for the .NET Framework 3.5. VS2008 should be able to open my project and upgrade it.
DevExpress Team
Your solution works fine but when i try to convert it to my project i got this error : "A primary key field specified via the KeyFieldName property is not found in the underlying data source.". Is it because i use Collection to load data source? Or are there any other reasons? Thank you.
mehmetserif