Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

update hidden field in gridview using javascript

Posted on 2010-11-10
3
Medium Priority
?
973 Views
Last Modified: 2012-05-10
I have a gridview which contains a hidden field and a check box. Some of the check boxes will be populated and some not.

Without postback the user will make some changes and click update. when it updates i only want to change the ones that have changed so i have added a hidden field and what i want to do is set the hidden field value to 1 only on those rows where a change is made. I'm thinking this can be done using js but i dont know how?
0
Comment
Question by:LBGUC04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Expert Comment

by:Tyler Laczko
ID: 34105458
document.getElementById("itemID").value  to get your value

document.getElementById("itemID").value = "1";
0
 
LVL 10

Expert Comment

by:P1ST0LPETE
ID: 34105980
You are right, that you can use JavaScript to do this, and professionalc is also right in how to set the value of a hidden field.  However, I think what you're looking for is a little bit more complicated than what his answer covers.  Can you provide the code for your gridview control, so we can see your actual grid make up and provide you with a better answer?
0
 
LVL 12

Accepted Solution

by:
jagssidurala earned 2000 total points
ID: 34108570
For example you have one text box and check box


.aspx
------------

<asp:gridview ......

<Columns>
<TemplateField>
<ItemTemplate>
<asp:checkBox onclick="fnUpdateHiddenvalue(this.tag)" tag="hdnUpdate" ...............</asp:checkBox>
<asp:Hiddenfield Id="hdnUpdate" .........../>
</ItemTemplate>
</TemplateField>

<TemplateField>
<ItemTemplate>
<asp:TextBox onblur="fnUpdateHiddenvalue(this.tag)" tag="hdnUpdate" ...............</asp:checkBox>
</ItemTemplate>
</TemplateField>

</Columns>

</asp:Gridview>


Js function
----------------

function fnUpdateHiddenvalue(hdnId)
{
document.getElementById(hdnId).value = "1";
}


Note: tag="hdnUpdate" , Where hdnUpdate is hidden field id, this code may varies if you use any master pages as hiddenfield rendered diffrently like ctl00_Contentplaceholder1_00_hdnUpdate.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question