This is a migrated thread and some comments may be shown as answers.

problem wiht setting values on update

3 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
roberto
Top achievements
Rank 1
roberto asked on 13 Feb 2011, 08:48 PM
Hi,

I'm having a problem when I try to set some value on a field. I have a GridTemplateColumn with a RadComboBox, and if some value in specific is selected a windows shows up and return a value. If I'm on insert mode I can put this value on the field whit this code

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
   GridDataItem item = (GridDataItem)combo.NamingContainer;
   HtmlInputText valor = (HtmlInputText)item.FindControl("Valor");
   valor.Value = e.Argument;
}

the combo variable is global and I obtain the value with this

protected void Op_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{   
   combo = (RadComboBox)sender;
}

this code works fine, but my problem comes when I try to update because doesn't change the value that the window returned.
I have this method
protected void ItemDataBound_condicion(object sender, GridItemEventArgs e)
{
     if (e.Item.IsInEditMode && e.Item is GridDataItem)
     {
        GridEditableItem item = e.Item as GridEditableItem;
        RadComboBox operador = (RadComboBox)item.FindControl("Operador");
        combo = operador;
        if (operador.SelectedValue == "En la lista" || operador.SelectedValue == "No en la lista")
        {
          valor = (HtmlInputText)item.FindControl("Valor");
          valor.Attributes.Add("onclick", "OnClientClick(valor.Value);
        }
    }
 }

I'm setting the combo to the RadComboBox of the row, and use the same code of the method RadAjaxManager1_AjaxRequest, but it doesn't work, only works when I change the value of  'Operador' but when I click the field 'Valor' doens't works.

Am I doing something wrong??

Thanks in advance.


3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Feb 2011, 07:19 AM
Hello Roberto,

I have found some issues with the code that you tried to attach the onclick event and I modified like below.
C#:
valor.Attributes.Add("onclick", "OnClientClick('"+valor.Value+"')");

Thanks,
Shinu.
0
roberto
Top achievements
Rank 1
answered on 14 Feb 2011, 04:28 PM
Hi Shinu

Thanks, I changed that part but still doesn't work...

I check the function that returns the value and works fine, with an alert I can see the value that is returned by the window, but I think that my problem is in this line inside the method RadAjaxManager1_AjaxRequest 
GridDataItem item = (GridDataItem)combo.NamingContainer;

becuase it works fine when I changed  the value of 'operador'
protected void Op_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{    
   combo = (RadComboBox)sender;
}

but when the onclick event is fired, I don't know if I'm getting the correct reference.

combo = operador; 

Thanks
0
Tsvetina
Telerik team
answered on 17 Feb 2011, 08:55 AM
Hello roberto,

Have you tried debugging your code to confirm that the combo is already available in the AjaxRequest event? It is possible that the combo is not yet initialized. If this is not the case, could you please provide more thorough code that could be used to create a runnable project, so we can look at the issue locally.

Kind regards,
Tsvetina
the Telerik team
Tags
Grid
Asked by
roberto
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
roberto
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or