I have a grid of users. In the edit form for editing or adding a user,
I have a 2 embedded grids - one is the default chosen package and there is one
price associated with that package, and the price is a hidden column in the
embedded grid. I take that price, and put it in a textbox to put in the form.
The second embedded grid is a list of additional items that can be added to
the existing package, and each line item can have it's own price, and I have
a column template of a radnumeric textbox that the user enters a price if they
want to add the item. I also have a textbox placed under the chosen package
price that should show the total price of all additional items chosen. And
finally I want a 3rd text box showing the grand total price.
I got the first text box working fine. My first problem is that
when a user changes the price in the grid, my footer and textbox of totals
do not change.
I have the text box being set in the itemdatabound call for the grid:
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
string price = dataItem["Price"].Text;
if (price == "")
price = "0";
int fieldValue = Convert.ToInt32(price);
int total = int.Parse(TextBoxTotalAlaCartePrice.Text);
total += fieldValue;
TextBoxTotalAlaCartePrice.Text = total.ToString();
}
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = e.Item as GridFooterItem;
int total = int.Parse(TextBoxTotalAlaCartePrice.Text);
footerItem["Price"].Text = "total: " + total.ToString();
}
And I also have an event handler when the user changes the
radnumeric text box, and I change the total there too:
protected void RadNumericTextBox1_TextChanged(object sender, EventArgs e)
{
RadNumericTextBox ntb = (RadNumericTextBox)sender;
string id = (ntb.NamingContainer as GridDataItem)["service_id"].Text.Trim();
string price = ntb.Value.ToString();
int nPrice = Convert.ToInt32(ntb.Value);
int nTotalPrice = Convert.ToInt32(TextBoxTotalAlaCartePrice.Text);
nTotalPrice += nPrice;
TextBoxTotalAlaCartePrice.Text = nTotalPrice.ToString(); //textbox that holds total alacarte price
//call to stored procedure to update temporary table with price change
Insert_update_price(TextBoxTempTableName.Text, TextBoxAdditionalItemsPackageCdAla.Text, Convert.ToInt32(id), Convert.ToInt32(price));
}
Any insight would be greatly appreciated.
Thanks,
Laura
I have a 2 embedded grids - one is the default chosen package and there is one
price associated with that package, and the price is a hidden column in the
embedded grid. I take that price, and put it in a textbox to put in the form.
The second embedded grid is a list of additional items that can be added to
the existing package, and each line item can have it's own price, and I have
a column template of a radnumeric textbox that the user enters a price if they
want to add the item. I also have a textbox placed under the chosen package
price that should show the total price of all additional items chosen. And
finally I want a 3rd text box showing the grand total price.
I got the first text box working fine. My first problem is that
when a user changes the price in the grid, my footer and textbox of totals
do not change.
I have the text box being set in the itemdatabound call for the grid:
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
string price = dataItem["Price"].Text;
if (price == "")
price = "0";
int fieldValue = Convert.ToInt32(price);
int total = int.Parse(TextBoxTotalAlaCartePrice.Text);
total += fieldValue;
TextBoxTotalAlaCartePrice.Text = total.ToString();
}
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = e.Item as GridFooterItem;
int total = int.Parse(TextBoxTotalAlaCartePrice.Text);
footerItem["Price"].Text = "total: " + total.ToString();
}
And I also have an event handler when the user changes the
radnumeric text box, and I change the total there too:
protected void RadNumericTextBox1_TextChanged(object sender, EventArgs e)
{
RadNumericTextBox ntb = (RadNumericTextBox)sender;
string id = (ntb.NamingContainer as GridDataItem)["service_id"].Text.Trim();
string price = ntb.Value.ToString();
int nPrice = Convert.ToInt32(ntb.Value);
int nTotalPrice = Convert.ToInt32(TextBoxTotalAlaCartePrice.Text);
nTotalPrice += nPrice;
TextBoxTotalAlaCartePrice.Text = nTotalPrice.ToString(); //textbox that holds total alacarte price
//call to stored procedure to update temporary table with price change
Insert_update_price(TextBoxTempTableName.Text, TextBoxAdditionalItemsPackageCdAla.Text, Convert.ToInt32(id), Convert.ToInt32(price));
}
Any insight would be greatly appreciated.
Thanks,
Laura