Repeater control

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

I have a dataRepeater control on a page, which lists me the headers of a
news.
When I click on a header I would like to show the news for this header.
Which is the best practice?

Have an anhor tag and redirects to the new page or show the text of a
selected news on the same page - I think the last one is better but I don't
know how to do it. Hide repeater control and show the text of selectd news
on some label or something like that?

Is there any suggestion or example?

Thank you,
Simon
 
| I have a dataRepeater control on a page, which lists me the headers of a
| news.
| <...> or show the text of a
| selected news on the same page - I think the last one is better <...>

Just some thoughts and non-working code:

<asp:Repeater id="Repeater1" runat="Server">
<ItemTemplate>
<div>
<%# displaySmth(DataBinder.Eval(Container.DataItem,"articleID")) %>
</div>
</ItemTemplate>
</asp:Repeater>

and displaySmth() is a function:

string displaySmth(object o)
{
if (o.ToString()==articleID_from_request_querystring) return
GetArticleTextByID(articleID_from_request_querystring);
else return link_to_this_page_with_articleID_as_parameter;
}

So after choosing third link you will have something like:

Link to article1

Link to article2

Article3 text

Link to article4

and so on...

Robke
 
Hi,

thank you for your answer.
Is there any chance to get the text from the repeater control?

when I have articleId, get the tekst like this:
displaySmth=Container.DataItem("articleText") or something like that
or I have to create an sql statement and dataSet and so on... again
- I mean I have all the data in the repeater control already

And one more question (still noone answer me):

When I press shortcut key F5 (Debug.startWithoutDebugging) I always get a
page on a new instance of Internet explorer.
So then happens that I have 10 or more opened windows.
Is it possible to reload the page with changes when I press F5 in the opened
window?

Thank you,
Simon
 
| thank you for your answer.
| Is there any chance to get the text from the repeater control?

Yes.

| when I have articleId, get the tekst like this:
| displaySmth=Container.DataItem("articleText")

No. I think you should pass the articleText together with articleID to your
function like this:
<%# displaySmth(DataBinder.Eval(Container.DataItem, "ID"),
DataBinder.Eval(Container.DataItem, "articleText")) %>

And your function now looks like this:

string displaySmth(object id, object text)
{
if (id.ToString()==articleID_from_request_querystring) return
text.ToString();
else return link_to_this_page_with_articleID_as_parameter;
}

| And one more question (still noone answer me):
| When I press shortcut key F5 (Debug.startWithoutDebugging) I always get a
| page on a new instance of Internet explorer.

Well, Ctrl+F5 is for Debug.startWithoutDebugging. I always press F5 and
start the project with debugging, so I never have more than one window
opened.

Robke
 
Thank you for your answer.

Further more is there any option to include at the end of the article some
kind of close link.
When you have article text displayed, you have at the end close button or
link, when you click it, you see only the articles titles again?

If I would like to see only article text without other titles then I have to
redirect to the other page?

I'm expert for transact SQL and all my business logic is in procedures, I'm
new at asp.net :)

Thank you again and best regards from Slovenia,
Simon
 
| Thank you for your answer.
|
| Further more is there any option to include at the end of the article some
| kind of close link.
| When you have article text displayed, you have at the end close button or
| link, when you click it, you see only the articles titles again?

You can add anything You like to the article text. Do it in that function
displaySmth(). i.e.:
....
return text.ToString()+"<a
href=\"the_same_page_WITHOUT_articleID_as_parameter\">Click here</a>";
....

If the page is called without articleID in query string, only article titles
will be displayed.

| If I would like to see only article text without other titles then I have
to
| redirect to the other page?

Well, you have two options here: reload the same page, hide Repeater control
and show article text or redirect to another page. I would prefer the second
one.

Robke
 
Back
Top