Click here to Skip to main content
15,883,996 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hello Professionals


there is need in ma project that there is some drop down list and text boxes
and a button ,i have to add data of all that text boxes and drop down list in grid view
on button click event

note : important thing is that i need to show virtually data on grid view through above condition not need to save all record on database and after this to fetch...

and also this task need to done only by jquery

thanks in advance
Posted
v2
Comments
What have you tried and where is the problem?
Shubh Agrahari 12-Dec-13 23:41pm    
Tadit using jQery i found all the value in a variable after Add button click but how i bind that values on grid view is occurring bit typical. if that value i fetching from database then it will be done using Ajax and Jason but there is condition that i need to stare data virtually on grid view and the issue is this stuff need to done with Jquery not with Server side languages like C#
Ok. You just need to add row on client side. No need to save or update the GridView at Server side, right? If I give you an example link, can you try this?
♥…ЯҠ…♥ 12-Dec-13 8:27am    
Nice requirement.... Hope you will get answer here ;-)
Karthik_Mahalingam 12-Dec-13 10:29am    
:-)

1 solution

GridView is rendered as a Table in client side browser.
So, you just need to append another row to that GridView (Table) using jQuery.
JavaScript
$('#<%=btnAdd.ClientID %>').bind('click', function (event) {
    var $grid = $('#<%=GridView1.ClientID %>');
    var $row = $grid.find('tr:last').clone().appendTo($grid);
    return false;
});
 
Share this answer
 
Comments
Shubh Agrahari 13-Dec-13 6:40am    
can you clearly describe it with proper structure with four column(one row).....also with taking data from controls on button click
$row refers to the newly created row. You just need to use that to find all the cells inside it and assign the values. Something like below...

$row.find('td:first').html('newValue');

Look, I have not tried this. But the idea is to find the tds inside that row and assign values to HTML. If you will see the generated HTML of the new row, you will be more clear.

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