Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI Guys,

I have a scenario like this.
JavaScript
if (row.visible)
{
    //do this
}
else
{
    //do that and
    row.visible = true;
}


This is working pretty fine when comes in the code for first time and shows the row properly.

after that I am using remove row function which is making row's visibility to hidden and display to none through JavaScript..

That is working too and hiding that row as well.. but problem comes after that ,, When I again come to the above code it is till showing

JavaScript
row.visible = true


although I have done
JavaScript
row.style.visibility = 'hidden';
and row.style.display = 'none';


... So Can any body give me idea how to do this scenario... :(
Posted
v2
Comments
If you want to remove it, you can do it easily.

Is there any reason to hide it? Let me know.
VICK 27-Sep-13 3:10am    
Actually Row is having a Gridview inside it.. and I am removing Gridview Rows through Javascript and when last row got removed than I am making visibility of whole Row containing Gridview to hidden.. and if user again click on add button than again row is showing up with those values.
But as you said I can remove the row.. So Will it effect the Gridview or Row design.??

I mean after removing a Row ,, Can It be shown again along with the content and css etc???
It will affect. Removing means deleting, so it can't be reverted.

Okay tell me one thing. Is the below code is in javaScript or Code Behind?

if (row.visible)
{
//do this
}
else
{
//do that and
row.visible = true;
}
VICK 27-Sep-13 3:27am    
:(
this is on Server side..i.e Code Behind.

Further if you dont mind can you clear my one more concept..
My working is like that..

I am populating Gridview through serverside without binding to DB,
Than I am removing some rows through JavaScript.

But If i try to get the data which is showing currently in Gridview on server side, than it is also showing the deleted data as well>>

Y is it so?? and how to just get the current data???
When you delete a row in javaScript, it is only deleted on client side.
If you want to completely delete it, then you have to delete the row from Database.

So, you can do a Ajax jQuery call to Web method on Server side. Then from that Web Method, you can run a SQL Script to delete that row from Database.

Got it?

1 solution

I think you have to set row visible value false before any operation you do. Because some time it will take last change value and generate wrong o/p so set it's value false then do any operation true or false like below :
JavaScript
row.visible = false;

if (row.visible)
{
    //do this
}
else
{
    //do that and
    row.visible = true;
}

Accept as answer and vote if help.
 
Share this answer
 
v3
Comments
VICK 27-Sep-13 1:46am    
But It will and It is making row.visible condition always false because row.visible is happening on the server side(codebehind).. Further let me clear you that its not taking last value as m doing in else on next iteration...Rather its not considering the changes i m doing through JavaScript....

SO Any other solution???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900