FormView

M

Miro

I am having a hard time understanding "Labels" within asp.net and
databinding.

I have a very simple xml file and I dropped an XMLDatasource onto the aspx
page.
Each "Node" has 3 dataparts...
<types>
<type id="1" desc="hello" age="12" />
<type id="2" desc="goodbye" age="33" />
</types>

I linked a combo box to the XMLDatasource
(Combo box displays all the proper available "Descriptions".
All works well... I have the value = id and the list is displaying the desc

Now, on the DropDownList1_SelectedIndexChanged i want to put code to update
a label on the aspx page with the 'Age' of the current id on the selected
item in the drop down list.

Here I am stumped.

I think I am a lot closer... I have a formview with an Item Template with a
label bound to the "Age" column.
But how do i change the Formview to be the record ID hit within the dropdown
list.

The dropdown list is "Outside" of the FormView so somehow I need to either
"Seek" the proper xmlDatarecord and make the formview link to that,
or get rid of the formview and just add Labels...and when I seek the record
( somehow ) on the dropdown list, I can just say
lblAge.text = bla

I do not know how to "seek" the xmldatafile as a datarow so I can extract my
columns or something.

Thanks,

Miro
 
G

Gregory A. Beamer

I do not know how to "seek" the xmldatafile as a datarow so I can
extract my columns or something.

LINQ to XML would be my first option, as it is easier to use than a
"traditional" XML approach. XPath or XQuery is the other route.

Peace and Grace,
 
G

Guest

I am having a hard time understanding "Labels" within asp.net and
databinding.

I have a very simple xml file and I dropped an XMLDatasource onto the aspx
page.
Each "Node" has 3 dataparts...
<types>
<type id="1" desc="hello" age="12" />
<type id="2" desc="goodbye" age="33" />
</types>

I linked a combo box to the XMLDatasource
(Combo box displays all the proper available "Descriptions".
All works well... I have the value = id and the list is displaying the desc

Now, on the DropDownList1_SelectedIndexChanged i want to put code to update
a label on the aspx page with the 'Age' of the current id on the selected
item in the drop down list.

Here I am stumped.

I think I am a lot closer... I have a formview with an Item Template with a
label bound to the "Age" column.
But how do i change the Formview to be the record ID hit within the dropdown
list.

The dropdown list is "Outside" of the FormView so somehow I need to either
"Seek" the proper xmlDatarecord and make the formview link to that,
or get rid of the formview and just add Labels...and when I seek the record
( somehow ) on the dropdown list, I can just say
lblAge.text = bla

I do not know how to "seek" the xmldatafile as a datarow so I can extract my
columns or something.

Thanks,

Miro

Following the same logic, you may add another XmlDataSource (e.g.
XmlDataSource2) and set

protected void DropDownList1_SelectedIndexChanged (...)
{

XmlDataSource2.Xpath = "/type[@id='" + DropDownList1.SelectedValue +
"']";

}

then your FormView could have something like this

<asp:FormView ... DataSourceID="XmlDataSource2">
<ItemTemplate>
<asp:Label ... Text='<%# XPath("@age") %>'
</ItemTemplate>
</asp:FormView>

I did not test it, but I think it should work in that way.

Hope this helps.
 
M

Miro

Thank you,

XQuery did the trick

Cheers'

Miro

Gregory A. Beamer said:
LINQ to XML would be my first option, as it is easier to use than a
"traditional" XML approach. XPath or XQuery is the other route.

Peace and Grace,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top