Solved

update hidden field in gridview using javascript

Posted on 2010-11-10
3
968 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 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 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