T
tshad
Using VS 2005:
I have a Datagrid or Gridview that will display Names and address and I want
to loop through them and collect the names to give to a javascript function.
I am trying to find the best way to do this.
At the moment, I am doing it through Page_PreRender where I just loop
through the grid using FindControl to get each name and append them together
in a hidden asp:Label control. I can then just use GetElementById to get
the string from the hidden label.
Sub Page_PreRender(ByVal Sender As Object, ByVal E As EventArgs)
Dim oLabel as WebControls.Label
for each oItem as DataGridItem in DataGrid1.Items
oLabel = CType(oItem.FindControl("FullName"),WebControls.Label)
if oLabel.Text = "" then SaveNames.Text = SaveNames.Text & "," &
oLabel.Text
Next
End Sub
Is there a way to this is Javascript using GetElementById or some other
function?
The Label is being turned into a link so that it looks something like:
<a id="ctl00_mContentPlaceHolder_dlResults_ctl01_FullName" class="name"
href="javascript:__doPostBack('ctl00$mContentPlaceHolder$dlResults$ctl01$FullName','')">Peter
Helton Do</a>
How can I loop through using Javascript to do the same thing when an event
if fired - or on entry to the page?
Thanks,
Tom
I have a Datagrid or Gridview that will display Names and address and I want
to loop through them and collect the names to give to a javascript function.
I am trying to find the best way to do this.
At the moment, I am doing it through Page_PreRender where I just loop
through the grid using FindControl to get each name and append them together
in a hidden asp:Label control. I can then just use GetElementById to get
the string from the hidden label.
Sub Page_PreRender(ByVal Sender As Object, ByVal E As EventArgs)
Dim oLabel as WebControls.Label
for each oItem as DataGridItem in DataGrid1.Items
oLabel = CType(oItem.FindControl("FullName"),WebControls.Label)
if oLabel.Text = "" then SaveNames.Text = SaveNames.Text & "," &
oLabel.Text
Next
End Sub
Is there a way to this is Javascript using GetElementById or some other
function?
The Label is being turned into a link so that it looks something like:
<a id="ctl00_mContentPlaceHolder_dlResults_ctl01_FullName" class="name"
href="javascript:__doPostBack('ctl00$mContentPlaceHolder$dlResults$ctl01$FullName','')">Peter
Helton Do</a>
How can I loop through using Javascript to do the same thing when an event
if fired - or on entry to the page?
Thanks,
Tom