M
Manish
Hey folks
I am having a weird problem in ASP .Net. My page is in C#. I have a
datagrid, which populates based on selection in drop down box on ASP
page. This datagrid has template textbox colum in itemtemplate.
Datagrid is something like this-
Category Week Amt Week% Button
Revenue 1 100 Update
Revenue 2 200 Update
Cost 1 25 25
Cost 2 40 20
Now I have procedure in itemcommand event of datagrid, which detects
if update button is pressed and this means that Cost number is
re-calculated based on corresponding week%. Therefore if user changes
Revenue for week 1 to 200, then Cost is recalculated for week 1 as 50.
When i click Update button, everything works, fine, page is re-posted
and cost is re-calculated as 50.
Although my user wants to update this number without having to click
button. He wants Cost number to be updated as soon as he hits enter on
textbox after changing revenue number.
I tried raising OnTextChange event on txtbox and writing same piece of
code I used on ItemCommand for button but when I hit enter after
changing number, page re-posts and it doesnt retain any changes i made
to revenue and subsequently in Cost value. Next I tried debugging by
printing number for Cost on a label text value. It did actually gave
me new value for Cost but when it re-populated grid, all changes were
gone. What could be wrong?
I also understand that I can run this calculation on client side
rather than going back to server, which is unnecessary, as I just need
to re-calculate Cost based on changed Revenue and Week%. For client
side, i can write some kind of javascript to make this update.
Am I thinking correct by trying to do something on client side using
javascript? If then any sample code to achieve this in javascript will
be appreciated. Alternatively, if it makes sense to do on server side,
than what could be wrong in my OnTextChange event?
Thanks in advance
Manish
I am having a weird problem in ASP .Net. My page is in C#. I have a
datagrid, which populates based on selection in drop down box on ASP
page. This datagrid has template textbox colum in itemtemplate.
Datagrid is something like this-
Category Week Amt Week% Button
Revenue 1 100 Update
Revenue 2 200 Update
Cost 1 25 25
Cost 2 40 20
Now I have procedure in itemcommand event of datagrid, which detects
if update button is pressed and this means that Cost number is
re-calculated based on corresponding week%. Therefore if user changes
Revenue for week 1 to 200, then Cost is recalculated for week 1 as 50.
When i click Update button, everything works, fine, page is re-posted
and cost is re-calculated as 50.
Although my user wants to update this number without having to click
button. He wants Cost number to be updated as soon as he hits enter on
textbox after changing revenue number.
I tried raising OnTextChange event on txtbox and writing same piece of
code I used on ItemCommand for button but when I hit enter after
changing number, page re-posts and it doesnt retain any changes i made
to revenue and subsequently in Cost value. Next I tried debugging by
printing number for Cost on a label text value. It did actually gave
me new value for Cost but when it re-populated grid, all changes were
gone. What could be wrong?
I also understand that I can run this calculation on client side
rather than going back to server, which is unnecessary, as I just need
to re-calculate Cost based on changed Revenue and Week%. For client
side, i can write some kind of javascript to make this update.
Am I thinking correct by trying to do something on client side using
javascript? If then any sample code to achieve this in javascript will
be appreciated. Alternatively, if it makes sense to do on server side,
than what could be wrong in my OnTextChange event?
Thanks in advance
Manish