Click here to Skip to main content
13,004,870 members (67,751 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have already add dynamic LinkButton in run time under a Search Button event.
The Code is here:
for (int i = 0; i < db.dataSet.Tables["searchResult"].Rows.Count; i++)
                LinkButton lnkSearch = new LinkButton();
                lnkSearch.Text = txtSearch.Text.ToString();
                lnkSearch.ID = "label" + i.ToString();
                //lnkSearch.AccessKey = db.dataSet.Tables["searchResult"].Rows[i][0].ToString();
                this.UpdatePanel1.ContentTemplateContainer.Controls.Add(new LiteralControl("<br/>"));

This working good when I am click in a search Button.
The Code is here:
protected void btnSearch_Click(object sender, EventArgs e)
            Page.Response.Redirect("Search.aspx?SearchKey=" + txtSearch.Text.ToString());

So, in my summary I have three pages: 1. Default.aspx and 2. Search.aspx and 3. SearchResult.aspx. The Default.aspx page is my start up project page. Here I have a TextBox and a Button for search. My approach is write string in TextBox then click in the Button then under the event of the Button I run a SQL query to pick up data from database.
Now, suppose I got 3 results as 3 Article's Names and their 3 .pdf links. I can show the 3 Articles Name by adding 3 LinkButton with the LinkButton Text property. But, I am confused how to add 3 PDF link with these LinkButton and when I would click the LinkButton that will open another page named SearchResult.aspx with the specific pdf file in iframe control which is in SearchResult.aspx file as for example if I click LinkButton-1 than I will find in SearchResult.aspx file in iframe control with Pdf-1.

This is my problem. If anybody help me than I will very thankful to you. Please help me. Thank You!
Posted 20-Jan-13 20:24pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There is a very simple solution but not the optimum solution .
You may use a HTML Formatting to do it .

In the design page

1. add Runat server DIV which will contain your Links

<div id="MyPDFs"  runat="server">

and in the code behind

1. replace your for loop with this loop

  for (int i = 0; i < db.dataSet.Tables["searchResult"].Rows.Count; i++)
            string PDFlink = string.Empty;  //Replace this with the link of the PDF
            string PDFTitle = string.Empty; //Replace this with the title of hte PDF
            MyPDFs.InnerHtml += "<a href='" + PDFlink + "'>" + PDFTitle + "</a><br />";

and as i told u it'snot the optimum but it works

you may use Binding Expression as well

Ahmed Mandur 21-Jan-13 9:03am
Thanks Sisir :)
UL UL ALBAB 21-Jan-13 4:23am
It's a great idea but, when I have click in this link I have to redirect SearchResult.aspx file then passing the pdf file link by querystring in the load_page of SearchResult.aspx. How can I do it?

Ahmed Mandur 21-Jan-13 9:03am
ok, let me ask a question
> do u mean by your words that you want the link that will be redirected contain the Query string ?
and please would u write how could u receive the query string to show the PDF file in the Load of the page

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170627.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100