hello everyone,
i have three dropdowns.based on the dropdown selection grid was loaded.after the gridview load i edit a cell value then automatically aother cell values are changed
first select three dropdowns and click on the button.then the grid was loaded.i have rowdatabound event.at the first time of gridloaded rowdatabound event was fired.
after then i want to change the cell value. i write a javascript
function for calculating the formula.
and my rowdatabound event code is here
If e.Row.RowType = DataControlRowType.DataRow Then
Dim txt2 As TextBox = DirectCast(e.Row.FindControl("textbox2"), TextBox)
Dim txt3 As TextBox = DirectCast(e.Row.FindControl("textbox3"), TextBox)
Dim lbl1 As Label = DirectCast(e.Row.FindControl("label1"), Label)
If e.Row.RowState = DataControlRowState.Edit Then
lbl1.Text = DGV1.Rows(DGV1.SelectedIndex).Cells(3).Text
txt2.Text = DGV1.Rows(DGV1.SelectedIndex).Cells(4).Text
txt3.Text = DGV1.Rows(DGV1.SelectedIndex).Cells(5).Text
End If
Session("txt2") = txt2.Text
Session("txt3") = txt3.Text
Session("lbl1") = lbl1.Text
txt2.Attributes.Add("onblur", "GetDAmt('" & lbl1.Text & "','" & txt2.Text & "','" & txt3.Text & "');")
End If
javascript function
function GetDAmt(mAmt,mPAmt,mDAmt)
{
var mmAmt=0;
var mmPAmt=0;
var mmDAmt=2;
var mmAmt = "<% = Session("lbl1") %>";
alert(mmAmt);
var mmPAmt = "<% = Session("txt2") %>";
alert(mmPAmt);
var mmDAmt = "<% = Session("txt3") %>";
alert(mmDAmt);
mmAmt=document.getElementById(mAmt).value;
mmPAmt=document.getElementById(mPAmt).value;
if (!isNaN(mmAmt))
{
mmDAmt=mmAmt-mmPAmt;
}
document.getElementById(mDAmt).value=mmDAmt;
}
but after the cellv alue changed rowdata bound event was not fired.so the values are all '0's and it gives the value as 0.
what is the problem here.any one help me with this
one thing iam working with asp.net and gridview.
pls not give the examples of windows application and datagrid
Loading
Roei BarPosted Sep 1, 2009, 1:07 AM
first thig you dont need the Session values
insted you can use
<% textbox.ClientID%> and so on in the JS
now regarding the RowDataBound it will occur only in the GridView Bind Command Call,
cellvaluechange does not call it, you can either fire the event on the cellvaluechange,
which i dont recommend since you will loose your changes, or create a submit botton to update the new records and then recall the gridview.DataBind event
hope this helps you out
dont forget to mark it as "Accepted Answer"
abhishek trivediPosted Sep 30, 2009, 8:58 AM
make this row editable by using edit button dont forget to make that button command name = 'edit' then on click of that button u need to display update and cancel button to update the cell values you changed.
i hope this will help you