2 Replies - 1482 Views - Last Post: 17 February 2011 - 10:26 AM

#1 Best123  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 05-August 10

add comma delimited string to a hiddenfield on my page

Posted 16 February 2011 - 08:10 PM

I have a asp.net gridview that displays client data. The first column on each row of the gridview is a checkbox. The second column on the gridview is client name and the third column is account holder. The user can select checkboxes (on multiple rows) to modify data (account holder).

I want to add clientName column value in a comma delimited string to a hiddenfield on my page.
How do I do that using javascript, as I do not want to use postback and looping through each row on the grid to get the checkbox status. When a checkbox is checked, it should append the hiddenfield value.

I am a newb on javascript. Please review my javascript code and suggest corrections. I am getting the hiddenfield value as blank, no matter what checkboxes are checked. I also know that my code is not targeting the correct row to get ClientName (row where checkbox is checked).

Any help is highly appreciated.

Thanks.
function RowClick(CheckBox) 
        {
            var BaseControl = document.getElementById('<%= this.myGrid.ClientID %>');
            var TargetControl = document.getElementById('MyHiddenField');
            for (var i = 0; i < BaseControl.rows.count; i++)
            {
                var rowElem = BaseControl.rows[i];
                for (var x = 0; x < rowElem.cells.count; x++) 
                {
                    var ClientName = rowElem.cells[1];
                    if (CheckBox.checked) TargetControl.Text += "," + Case_Id;
                }
            }
        }



Is This A Good Question/Topic? 0
  • +

Replies To: add comma delimited string to a hiddenfield on my page

#2 forest51690  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 58
  • View blog
  • Posts: 340
  • Joined: 20-March 09

Re: add comma delimited string to a hiddenfield on my page

Posted 16 February 2011 - 09:17 PM

It's TargetControl.value, not .Text.
Was This Post Helpful? 0
  • +
  • -

#3 Guest_Best123*


Reputation:

Re: add comma delimited string to a hiddenfield on my page

Posted 17 February 2011 - 10:26 AM

The target control is referring to a asp:hiddenfield. it is text.

thanks.
Was This Post Helpful? 0

Page 1 of 1