Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a requirement to know the id of a job that is applied by the user. Here initially the user clicks on a drop down list to view jobs based on his/her search criteria. After that the user can click on any of the jobs that is displayed on the page. For that i have link buttons. But the link buttons are not firing on the click event. Please help me.

C#
SqlCommand cmd = new SqlCommand();
        int ID = 0;

        try
        {
            cmd.Connection = con;

            cmd.CommandText = "SELECT TOP(10) s_JobDesignation,s_JobDescription,s_NoOfVacancies,s_DatePosted,s_JobCategoryID FROM [OfinityJobSearch].[dbo].[tx_ListOfJobs] WHERE s_IndustryName='" + industryName + "' ORDER BY s_JobId ASC ";
            cmd.CommandType = CommandType.Text;   if (cmd.Connection.State == ConnectionState.Closed)
                cmd.Connection.Open();
 using (SqlDataReader reader = cmd.ExecuteReader()) {
              
                if (reader.HasRows)
                {
                    
                    while (reader.Read())
                    {

                        JobDesignation = reader.GetString(0);
                        JobDescription = reader.GetString(1);
                        NoOfVacancies = Convert.ToString(reader.GetInt32(2));
                        DatePosted = Convert.ToString(reader.GetDateTime(3)).Replace("00:00:00", "");
                        jobId = reader.GetString(4);
                        int tblRows = 1;
                        int tblCols = 1;
                      
                        Table tbl = new Table();
                        PlaceHolder1.Controls.Add(tbl);
                        for (int i = 0; i < tblRows; i++)
                        {
                            readerrowcount = readerrowcount + 1;
                            TableRow tr = new TableRow();
                            tr.CssClass = "rowStyle1";
                            for (int j = 0; j < tblCols; j++)
                            {
                                TableCell tc = new TableCell();
                                tc.CssClass = "cellStyle1";
                               System.Web.UI.WebControls.Label txtBox = new System.Web.UI.WebControls.Label();
                               txtBox.Text = "Job ID:" + jobId + "<br />" + "Job Designation:" + JobDesignation + "<br />" + "Job Description:" + JobDescription + "<br />" + "Vacancies:" + NoOfVacancies + "<br />" + "Ad Posted On:" + DatePosted + "<br />"+"";
                               tc.Controls.Add(txtBox);
                               tr.Cells.Add(tc);
                               System.Web.UI.WebControls.LinkButton lbView = new System.Web.UI.WebControls.LinkButton();
                               lbView.Text = "<br />" + "Apply for this Job";
                               lbView.Click += new EventHandler(lbView_Click);
                               lbView.OnClientClick = "return RedirectTo('" + id + "')";
                               tc.Controls.Add(lbView);
                               tr.Cells.Add(tc);}   tbl.Rows.Add(tr);

                        }
                        ViewState["dynamictable"] = true; 
                      } reader.NextResult();
                    
                }
                
            } 

        }


Here the lbView.Click event is not firing at all. Can you tell me where i went wrong?
Posted
Comments
Dholakiya Ankit 11-Aug-13 23:27pm    
is ur lbview inside update panel? have you applied trigger in ur code?
Chaithannya 12-Aug-13 3:25am    
No. Its not in update panel.

1 solution

SQL
Try it in JQuery...Write the below code with in document ready function of jQuery.

$(document).ready(function(){
  $("#id_of_dynamic_link_button").live("click", function () {
       alert("Link_return button fired successfully");
    });


});
 
Share this answer
 

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



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