Click here to Skip to main content
15,892,697 members

Add multiple link in multiple LinkButton in runtime

UL UL ALBAB asked:

Open original thread
I have already add dynamic LinkButton in run time under a Search Button event.
The Code is here:
C#
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(lnkSearch);
                this.UpdatePanel1.ContentTemplateContainer.Controls.Add(new LiteralControl("<br/>"));
}

This working good when I am click in a search Button.
The Code is here:
C#
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!
Tags: C#, ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900