Hi everybody,
I'm new on Telerik.
I wrote this code below, for CRUD operations:
The insert command worked perfectly, but Update did not.
On first attemp
On second attemp item.UpdateValues(obj); do nothing
Anybody can help me?
Thanks in advance.
I'm new on Telerik.
I wrote this code below, for CRUD operations:
The insert command worked perfectly, but Update did not.
On first attemp
(TextBox)e.Item.FindControl(
"txtComponente"
);
return null, and I do not understand why On second attemp item.UpdateValues(obj); do nothing
Anybody can help me?
Thanks in advance.
public
void
RadGrid1_ItemComand(Object sender , GridCommandEventArgs e)
{
switch
(e.CommandName)
{
case
"Insert"
:
try
{
TextBox txtComponente = (TextBox)e.Item.FindControl(
"txtComponente"
);
TextBox txtDescricaoComponente = (TextBox)e.Item.FindControl(
"txtDescricaoComponente"
);
Inserir(txtComponente.Text, txtDescricaoComponente.Text);
DisplayMessage(
false
,
"Sucess!"
);
Response.Redirect(
"ConsultaComponente.aspx"
);
}
catch
( Exception ex)
{
DisplayMessage(
true
, ex.Message);
}
break
;
case
"Update"
:
try
{
//First attempt
var ID = item.GetDataKeyValue(
"IdComponente"
).ToString();
TextBox txtComponente = (TextBox)e.Item.FindControl(
"txtComponente"
);
TextBox txtDescricaoComponente = (TextBox)e.Item.FindControl(
"txtDescricaoComponente"
);
Update(ID,txtComponente.Text, txtDescricaoComponente.Text);
//Second attempt
GridEditableItem item = e.Item
as
GridEditableItem;
var ID = item.GetDataKeyValue(
"IdComponente"
).ToString();
Componente obj = ComponenteController.Consulta(Convert.ToInt32(ID));
item.UpdateValues(obj);
Update(obj)
}
catch
(Exception ex)
{
DisplayMessage(
true
, ex.Message);
}
break
;
}