Need to get a Hiddenfield falue?

Posted by Samy33 under JavaScript on 8/17/2010 | Points: 10 | Views : 4067 | Status : [Member] | Replies : 4
In my project i am having gridview in that one hidden filed is there.Gridview Source
<asp:GridView ID="gdReport" runat="server" AutoGenerateColumns="False" Height="60%" Width="60%" TabIndex="23" ShowHeader="false">
<Columns>
<asp:BoundField HeaderText="Param Name" DataField="S_PARAM_NAME" />
<asp:BoundField HeaderText="Manadatory" DataField="S_MANDATORY" visible="false" />
<asp:BoundField HeaderText="Data Type" DataField="S_DATATYPE" visible="false"/>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="lbldatetype" runat="server" Value='<%# Eval("S_DATATYPE") %>'/>
</ItemTemplate>
</asp:TemplateField>
</asp:Gridview>
This is the script for getting values
document.forms[0].onsubmit=function() {
var refFlag = false;
if(srcButton.indexOf('$imgbtnViewReport')==-1 || srcButton.indexOf('$imgbtnClear')==-1 || srcButton.indexOf('$imgbtnExit')==-1)
{
refFlag=true;
}
return refFlag;
}
var reportTable = document.getElementById('ctl00_ContentPlaceHolder2_gdReport');
if('undefined'!=(''+reportTable) && reportTable!=null)
{
var allTrs = reportTable.getElementsByTagName("tr");
if('undefined'!=(''+allTrs) && allTrs!=null)
{
for(i=0;i<allTrs.length;i++)
{
var rowTds = allTrs[i].getElementsByTagName("td");
if (rowTds[1]!=undefined)
{
if(rowTds[1].innerHTML=="DATE")
{
allInputs = allTrs[i].getElementsByTagName("INPUT");
for(j=0;j<allInputs.length;j++)
{
if(allInputs[j].type=="submit")
{
allInputs[j].setAttribute('rowNum',i);
allInputs[j].onclick=showlov1;
}
}
}
else
{
allInputs = allTrs[i].getElementsByTagName("INPUT");
for(j=0;j<allInputs.length;j++)
{
if(allInputs[j].type=="submit")
{
allInputs[j].setAttribute('rowNum',i);
allInputs[j].onclick=ShowDialog;
}
}
}
}
}
}
}
it shows value like
<input type="hidden" Value=DATE ID="ctl00_ContentPlaceHolder2_gdReport_ctl02_lbldatetype">
inthat I need only the Value filed DATE How I can Get the Date value from using above javascript.
If any body knows the answer ,Please help me




Responses

Posted by: Vuyiswamb on: 8/17/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
try this

var MyhiddenField= document.getElementById("<%= ctl00_ContentPlaceHolder2_gdReport_ctl02_lbldatetype.ClientID %>");


Thank you for posting at Dotnetfunda
[Administrator]

Samy33, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shankul2784 on: 8/17/2010 [Member] Bronze | Points: 25

Up
0
Down
Hi,

var MyhiddenField= document.getElementById('ctl00_ContentPlaceHolder2_gdReport_ctl02_lbldatetype');

I hope, this will help you.

Thanks & Regards,

Shailesh

Samy33, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Samy33 on: 8/18/2010 [Member] Starter | Points: 25

Up
0
Down

I put this coding it shows error like below
Name 'ctl00_ContentPlaceHolder2_gdReport_ctl02_lbldatetype' is not declared.


Samy33, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Samy33 on: 8/18/2010 [Member] Starter | Points: 25

Up
0
Down
Here i need to get the value from Hiddenfield in gridview,In my gridview has 5 rows in five rows contains different Hidden field value like DATE,STRING,NUMBER like that.In First row and Second row Hidden field value is DATE. But third roe value is STRING.BUT it Shows Same DATE Value for 3 row 4 row as well as 5 th Row also.I need to get DATE as well as STRING Values.HOw can we get the Hiddenfield in every row

Samy33, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response