hey everyone,
I have a radgrid,under whoch i've a textbox and 2 label.I want to show product of label1 and textbox on OnBlur property of text box into the second label.I am doing this--
Can't find the controls its showing errors.Also is this proper way of finding product?....
plz help..
Thanks
Amit
I have a radgrid,under whoch i've a textbox and 2 label.I want to show product of label1 and textbox on OnBlur property of text box into the second label.I am doing this--
<
script
type
=
"text/javascript"
>
function FillAmount(sender, args)
{
var grid = $find("<%=RadGrid1.ClientID %>");
var MasterTable = grid.get_MasterTableView();
var txtQuantityE = $find('<%= txtQuantityE.ClientID %>')
var lblRate = $find('<%= lblRate.ClientID %>');
var lblAmount = $find('<%= lblAmount.ClientID %>');
var Amount = $find(Number(txtQuantityE.value)*Number(lblRate.Text)).get_value();
$find(lblAmount).set_value(Amount);
}
</
script
>
aspx has this under RadNumericTextBox <ClientEvents OnBlur="FillAmount" />
plz help..
Thanks
Amit
5 Answers, 1 is accepted
0

Amit
Top achievements
Rank 1
answered on 20 Oct 2010, 07:04 AM
Now,i've modified my code to this........
now,i am able to find controls,and there is no error...But the product is not visible on lblAmount on OnBlur event of textbox txtQuantityE.
i think this is something to do wid this line --
Is this syntax proper?...Any suggestions
Thanks
Amit
function
FillAmount(sender, args)
{
var
masterTable = $find(
"<%=RadGrid1.ClientID%>"
).get_masterTableView();
var
txtQuantityE = masterTable.get_dataItems()[0].findControl(
'txtQuantityE'
);
var
lblRate = masterTable.get_dataItems()[0].findControl(
'lblRate'
);
var
lblAmount = masterTable.get_dataItems()[0].findControl(
'lblAmount'
);
var
Amount = $find(Number(txtQuantityE.value)*Number(lblRate.Text)).get_value();
$find(lblAmount).set_value(Amount);
}
</script>
i think this is something to do wid this line --
Number(txtQuantityE.value)*Number(lblRate.Text)
.Is this syntax proper?...Any suggestions
Thanks
Amit
0
Accepted

Princy
Top achievements
Rank 2
answered on 20 Oct 2010, 09:41 AM
Hello Amit,
Please go through the following forum link which explains the same requirement and make necessary modification.
Change Cell value?
Thanks,
Princy.
Please go through the following forum link which explains the same requirement and make necessary modification.
Change Cell value?
Thanks,
Princy.
0

Amit
Top achievements
Rank 1
answered on 20 Oct 2010, 10:42 AM
Thanks a lot Princy,that was exactly what i was looking for?....
0

Amit
Top achievements
Rank 1
answered on 20 Oct 2010, 10:58 AM
hey,
I have one more doubt,as the label(lblAmount) is filled using client side event OnBlur.How will i get the value of this label in my data Table.
1. This is returning null,Shows no value within it.
2. And also every time i click save button the whole event runs twice and thus same values are inserted twice into the dataTable.
3. The grid shows the saved values twice.But when i click Add button again to insert new record,the previous values get cleared from the data table.
Thanks
I have one more doubt,as the label(lblAmount) is filled using client side event OnBlur.How will i get the value of this label in my data Table.
protected
void
Save_Click(
object
sender, EventArgs e)
{
Button Save = (Button)sender;
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)Save.NamingContainer;
RadComboBox combo = insertItem.FindControl(
"RadComboBox1"
)
as
RadComboBox;
Label lblRate = (Label)insertItem.FindControl(
"lblRate"
);
RadNumericTextBox txtQauntityE = (RadNumericTextBox)insertItem.FindControl(
"txtQuantityE"
);
Label lblAmount = (Label)insertItem.FindControl(
"lblAmount"
);
if
(combo.SelectedIndex > 0 && txtQauntityE.Text !=
null
)
{
DataRow drValues = dtValues.NewRow();
drValues[
"Items"
] = combo.SelectedItem.Text;
drValues[
"Rate"
] = lblRate.Text;
drValues[
"Quantity"
] = txtQauntityE.Text;
drValues[
"Amount"
] = lblAmount.Text;
dtValues.Rows.Add(drValues);
dtValues.AcceptChanges();
RadGrid1.DataSource = dtValues;
RadGrid1.Rebind();
RadGrid1.MasterTableView.IsItemInserted =
false
;
RadGrid1.MasterTableView.Rebind();
}
else
{
}
}
drValues[
"Amount"
] = lblAmount.Text;
1. This is returning null,Shows no value within it.
2. And also every time i click save button the whole event runs twice and thus same values are inserted twice into the dataTable.
3. The grid shows the saved values twice.But when i click Add button again to insert new record,the previous values get cleared from the data table.
Thanks
0
Hello Amit,
I assume your Save button is in some custom edit form. You should not set the data source of the grid in the click handler. You need to use advanced databinding using the NeedDataSource event. In the Save click handler, you need to call only RadGrid1.Rebind() and only once:
Veli
the Telerik team
I assume your Save button is in some custom edit form. You should not set the data source of the grid in the click handler. You need to use advanced databinding using the NeedDataSource event. In the Save click handler, you need to call only RadGrid1.Rebind() and only once:
RadGrid1.DataSource = dtValues;
//REMOVE!
RadGrid1.Rebind();
//REMOVE!
RadGrid1.MasterTableView.IsItemInserted =
false
;
RadGrid1.MasterTableView.Rebind();
Veli
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items