Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Scenario

i have a grid. There are 4 columns

1)checkbox[header checkbox]
2)location
3)distance1 (user will enter distance)
4)distance2(user will eneter distance)

--after distance1 is updated

--a check box i will click ...which will copy all the distance that is in column3 (that is distance1) to (distance2 column)

--i need to do this using jquery

--help me

--how to get also grideview cell using jquery
like column3 row1
column3 row2
column3 row3
--because once i know how to get the gridview cell value....i can assign those
to column4 row1
column4 row2
and so on


Kindly help me in this
Posted

1 solution

try to retrieve the value like this

$(document).ready(function () {
$("#GridViewID input[type=checkbox]").click(function() {
$("#<%=GridView3.ClientID%> input[id*='chkboxID']:checked").each(function () {
alert($('.Column3ID').text());
});
});
});

Once the value is retrieved you can set it to the distant2 cell

Hope this helps
 
Share this answer
 
v2
Comments
anurag19289 22-Sep-13 9:53am    
I tried this:

<script type="text/javascript">
$(function(){
$('[id*=chkbcopy]').click(function(){
var chkHeader = $(this);
if (chkHeader.is(":checked"))
{

$("[id*='txtdistancectv']").val($("[id*='txtdistanceops']").val());

}
else
{
$("[id*='txtdistancectv']").val('');

}


});

});



</script>


--but its copying the first row of gridview to all the text box.
--means if if in column1 the values are 3 4 5 6
--coulumn two values are fetched ike 3 3 3 3


--aspx page
<asp:TemplateField HeaderText="Approved Km By CTV" Visible="false">
<HeaderTemplate>
<asp:CheckBox ID="chkbcopy" runat="server" Text="Approved Km By CTV"/>
</HeaderTemplate>
<itemtemplate>
<asp:TextBox ID="txtdistancectv" MaxLength="6" class="test" CssClass="textBox_for6tds" runat="server">

<itemstyle horizontalalign="center">
anurag19289 22-Sep-13 9:53am    
Kindly help me ...
anurag19289 22-Sep-13 9:59am    
I tried this too :

<script type="text/javascript">
$(function(){
$('[id*=chkbcopy]').click(function(){
var chkHeader = $(this);
if (chkHeader.is(":checked"))
{

$("[id*='GridZeroApprovedKm'] tr").each(function () {

$("[id*='txtdistancectv']").val($("[id*='txtdistanceops']").val());


});
}
else
{
$("[id*='txtdistancectv']").val('');

}


});

});


--but the same result

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