Dear all,
i have a gridview inside gridview linkbutton as a(lbStatus) will be there but i wrote onclientclick event but its not firing pls help me asap.
i want to disply a popup for updating the status but event is not firing pls help me.
Serchcunsultatnt.aspx
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site1.Master" EnableEventValidation="false" CodeBehind="Search_Consultants.aspx.cs" Inherits="Gateway.Web.Admin.Search_Consultants" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
CancelControlID="btnShow" BackgroundCssClass="modalBackground">
CancelControlID="Button3" BackgroundCssClass="modalBackground">
.
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
| ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||
AutoGenerateColumns="False" DataKeyNames="id" OnPageIndexChanging ="gvRef_PageIndexChanging" PageSize="15" AllowPaging="true" OnRowDataBound="gvRef_RowDataBound" OnSorting="gvRef_Sorting" OnRowCommand="gvRef_RowCommand"> No Profiles ... | ||||||||||||||||||||||||||||||
| Do You Want to Change Status? | |
| Send E-mail | |
| TO | |
| CC | |
| BCC | |
| Subject | |
| Attachments | |
Serchcunsultatnt.aspx .cs
protected void gvRef_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink hldownload = new HyperLink();
//LinkButton lbStatus = new LinkButton();
//lbStatus = (LinkButton)e.Row.FindControl("lbStatus");
hldownload = (HyperLink)e.Row.FindControl("hldownload");
HyperLink hlFp = new HyperLink();
hlFp = (HyperLink)e.Row.FindControl("hlFp");
Label lblOpId = new Label();
lblOpId = (Label)e.Row.FindControl("lblOpId") as Label;
LinkButton lbStatus = e.Row.FindControl("lbStatus") as LinkButton;
//lbStatus.Click += new EventHandler(lbStatus_Click);
lbStatus.Command += new CommandEventHandler(lbStatus_Click);
HyperLink hlEdit = new HyperLink();
hlEdit = (HyperLink)e.Row.FindControl("hlEdit");
hlEdit.Visible = false;
lbStatus.Visible = false;
int conId = Convert.ToInt32(lblOpId.Text);
var temp = objCs.GetConsultantDetails(conId);
//if(temp == null)
// hlEdit.Visible = true;
int roleId = objUser.GetUserRoleDetails(Page.User.Identity.Name);
if (objUser.GetUserRoleDetails(Page.User.Identity.Name) < 3)
{
hlEdit.Visible = true;
lbStatus.Visible = true;
}
else if (temp.submitted_by == objUser.GetUserIdByName(Page.User.Identity.Name))
{
hlEdit.Visible = true;
lbStatus.Visible = true;
}
if (temp.resume != null)
hldownload.Enabled = true;
else
hldownload.Visible = false;
if (temp.formatted_resume != null)
hlFp.Visible = true;
else
hlFp.Visible = false;
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink hldownload = new HyperLink();
//LinkButton lbStatus = new LinkButton();
//lbStatus = (LinkButton)e.Row.FindControl("lbStatus");
hldownload = (HyperLink)e.Row.FindControl("hldownload");
HyperLink hlFp = new HyperLink();
hlFp = (HyperLink)e.Row.FindControl("hlFp");
Label lblOpId = new Label();
lblOpId = (Label)e.Row.FindControl("lblOpId") as Label;
LinkButton lbStatus = e.Row.FindControl("lbStatus") as LinkButton;
//lbStatus.Click += new EventHandler(lbStatus_Click);
lbStatus.Command += new CommandEventHandler(lbStatus_Click);
HyperLink hlEdit = new HyperLink();
hlEdit = (HyperLink)e.Row.FindControl("hlEdit");
hlEdit.Visible = false;
lbStatus.Visible = false;
int conId = Convert.ToInt32(lblOpId.Text);
var temp = objCs.GetConsultantDetails(conId);
//if(temp == null)
// hlEdit.Visible = true;
int roleId = objUser.GetUserRoleDetails(Page.User.Identity.Name);
if (objUser.GetUserRoleDetails(Page.User.Identity.Name) < 3)
{
hlEdit.Visible = true;
lbStatus.Visible = true;
}
else if (temp.submitted_by == objUser.GetUserIdByName(Page.User.Identity.Name))
{
hlEdit.Visible = true;
lbStatus.Visible = true;
}
if (temp.resume != null)
hldownload.Enabled = true;
else
hldownload.Visible = false;
if (temp.formatted_resume != null)
hlFp.Visible = true;
else
hlFp.Visible = false;
}
}
protected void lbStatus_Click(object sender, CommandEventArgs e)
{
LinkButton link = (LinkButton)sender;
GridViewRow grdrow = (GridViewRow)(link.Parent.Parent);
//GridViewRow grdrow = (GridViewRow)((LinkButton)sender).NamingContainer;
LinkButton id = (LinkButton)grdrow.FindControl("lbStatus");
userClass objUser = new userClass();
int? userId = objUser.GetUserIdByName(Page.User.Identity.Name);
pnlPopup.Visible = true;
if (grdrow != null)
{
// Label lblId = (Label)grdrow.FindControl("lblOpId");
// objRequirement.DeAssignedTask(lblId.Text, userId);
int? pStaus = objCs.GetProfileStatusId(Convert.ToInt32(id));
ddlChangeStatus.SelectedValue = pStaus.ToString();
ViewState["ChangeStatus"] = id;
}
mpe.Show();
}
{
LinkButton link = (LinkButton)sender;
GridViewRow grdrow = (GridViewRow)(link.Parent.Parent);
//GridViewRow grdrow = (GridViewRow)((LinkButton)sender).NamingContainer;
LinkButton id = (LinkButton)grdrow.FindControl("lbStatus");
userClass objUser = new userClass();
int? userId = objUser.GetUserIdByName(Page.User.Identity.Name);
pnlPopup.Visible = true;
if (grdrow != null)
{
// Label lblId = (Label)grdrow.FindControl("lblOpId");
// objRequirement.DeAssignedTask(lblId.Text, userId);
int? pStaus = objCs.GetProfileStatusId(Convert.ToInt32(id));
ddlChangeStatus.SelectedValue = pStaus.ToString();
ViewState["ChangeStatus"] = id;
}
mpe.Show();
}
private void LoadGridView()
{
GatewayEntities gt = new GatewayEntities();
IFormatProvider culture = new CultureInfo("en-US", true);
string opName = "0"; int? opCode = 0; string canName = "0"; string emilId = "0"; string mobile = "0"; string notice = "0";
string recName = "0"; string keySkill = "0"; int profStatus = 0; int countryId = 0;
DateTime? postedDate = Convert.ToDateTime("01/01/2000");
int clientId = 0;
DateTime fDate = Convert.ToDateTime("01/01/2000");
DateTime tDate = Convert.ToDateTime("01/01/2000");
if (Request.QueryString.Count == 2 && Session["click"] == null)
{
ddlProfStatus.SelectedIndex = ddlProfStatus.Items.IndexOf(ddlProfStatus.Items.FindByText(Request.QueryString[1].ToString()));
}
else if (Request.QueryString.Count >= 3 && Session["click"] == null)
{
ddlProfStatus.SelectedIndex = ddlProfStatus.Items.IndexOf(ddlProfStatus.Items.FindByText(Request.QueryString[2].ToString()));
}
if (txtOpeningName.Text != string.Empty)
opName = txtOpeningName.Text;
if (txtOpeningCode.Text != string.Empty)
opCode = Convert.ToInt32(txtOpeningCode.Text.Trim());
else
opCode = null;
if (txtCandidateName.Text != string.Empty)
canName = txtCandidateName.Text;
if (txtEmailId.Text != string.Empty)
emilId = txtEmailId.Text;
if (txtMobile.Text != string.Empty)
mobile = txtMobile.Text;
if (txtNotice.Text != string.Empty)
notice = txtNotice.Text;
if (txtRecruiterName.Text != string.Empty)
recName = txtRecruiterName.Text;
if (txtKeySkill.Text.Length > 0)
keySkill = txtKeySkill.Text;
if (ddlProfStatus.SelectedIndex > 0)
profStatus = Convert.ToInt32(ddlProfStatus.SelectedValue);
if (txtPostedDate.Text.Length > 0)
{
DateTime dts = Convert.ToDateTime(txtPostedDate.Text);
postedDate = dts;// (DateTime.ParseExact(dts, "dd/MM/yyyy", culture)).ToShortDateString(); //Convert.ToDateTime(Convert.ToDateTime(txtPostedDate.Text).ToShortDateString());
}
if (ddlCountry.SelectedIndex > 0)
countryId = Convert.ToInt32(ddlCountry.SelectedValue);
//client search from todate
if (ddlClient.SelectedIndex > 0)
clientId = Convert.ToInt32(ddlClient.SelectedValue);
if (txtFroDate.Text.Length > 0)
fDate = Convert.ToDateTime(txtFroDate.Text);
if (txtToDate.Text.Length > 0)
tDate = Convert.ToDateTime(txtToDate.Text);
Session["searchCo"] = null;
Session["searchCo"] = opName.ToString()+","+opCode+","+canName+","+emilId+","+mobile+","+notice+","+recName+","+keySkill+","+profStatus+","+postedDate+","+countryId;
if (ViewState["export"] != null )
{
//FOR EXPORT TO EXCEL
int id = 0;
var exp = gt.usp_search_profiles_client_dates101(opName, opCode == null ? 0 : opCode, canName, emilId, mobile, notice, recName, (opCode == 0 && opCode != null) ? "2" : "0", keySkill, profStatus, countryId,fDate,tDate,clientId).ToList();
var expo = (from c in exp
select new
{
Id = c.id,
CandidateName = c.candidate_name,
opening_name = c.opening_name,
Client = c.Client,
PostedDate = c.submitted_date,
Recruiter = c.submitted_by_name,
KeySkills = c.key_skills,
Exp = c.exp_years,
ContactNumber = c.contact_number,
AvailToJoin = c.notice_period,
CurrentLocation = c.current_location,
CurrentPackage = c.current_package,
OfferedPackage = c.proposed_package,
ConsultCheck = ConsultChecked(c.id),
EmpType =c.EMP_TYPE
}).ToList();
GridView1.AllowPaging = false;
CheckBox chk = (CheckBox)gvRef.HeaderRow.FindControl("chkAll");
if (chk.Checked == true)
GridView1.DataSource = expo.ToList();
else
GridView1.DataSource = expo.Where(d => d.ConsultCheck == "true").ToList();
GridView1.DataBind();
GridView1.Visible = true;
if (GridView1.Rows.Count > 0)
{
lblMsg.Text = "";
}
else
{
lblMsg.Text = "Please Select Profiles and Click again";
return;
}
//FOR EXPORT TO EXCEL
}
else
{
gvRef.DataSource = objCs.GetConsultants(opName, opCode, canName, emilId, mobile, notice, recName, keySkill, profStatus, countryId, fDate, tDate, clientId);
gvRef.DataBind();
///count
int RecordsCount = gt.usp_search_profiles_client_dates101(opName, opCode == null ? 0 : opCode, canName, emilId, mobile, notice, recName, (opCode == 0 && opCode != null) ? "2" : "0", keySkill, profStatus, countryId,fDate,tDate,clientId).ToList().Count();
lblSearchCount.Text = RecordsCount > 0 ? RecordsCount.ToString() + " Records found.." : "No Records found";
}
gt = null;
}
{
GatewayEntities gt = new GatewayEntities();
IFormatProvider culture = new CultureInfo("en-US", true);
string opName = "0"; int? opCode = 0; string canName = "0"; string emilId = "0"; string mobile = "0"; string notice = "0";
string recName = "0"; string keySkill = "0"; int profStatus = 0; int countryId = 0;
DateTime? postedDate = Convert.ToDateTime("01/01/2000");
int clientId = 0;
DateTime fDate = Convert.ToDateTime("01/01/2000");
DateTime tDate = Convert.ToDateTime("01/01/2000");
if (Request.QueryString.Count == 2 && Session["click"] == null)
{
ddlProfStatus.SelectedIndex = ddlProfStatus.Items.IndexOf(ddlProfStatus.Items.FindByText(Request.QueryString[1].ToString()));
}
else if (Request.QueryString.Count >= 3 && Session["click"] == null)
{
ddlProfStatus.SelectedIndex = ddlProfStatus.Items.IndexOf(ddlProfStatus.Items.FindByText(Request.QueryString[2].ToString()));
}
if (txtOpeningName.Text != string.Empty)
opName = txtOpeningName.Text;
if (txtOpeningCode.Text != string.Empty)
opCode = Convert.ToInt32(txtOpeningCode.Text.Trim());
else
opCode = null;
if (txtCandidateName.Text != string.Empty)
canName = txtCandidateName.Text;
if (txtEmailId.Text != string.Empty)
emilId = txtEmailId.Text;
if (txtMobile.Text != string.Empty)
mobile = txtMobile.Text;
if (txtNotice.Text != string.Empty)
notice = txtNotice.Text;
if (txtRecruiterName.Text != string.Empty)
recName = txtRecruiterName.Text;
if (txtKeySkill.Text.Length > 0)
keySkill = txtKeySkill.Text;
if (ddlProfStatus.SelectedIndex > 0)
profStatus = Convert.ToInt32(ddlProfStatus.SelectedValue);
if (txtPostedDate.Text.Length > 0)
{
DateTime dts = Convert.ToDateTime(txtPostedDate.Text);
postedDate = dts;// (DateTime.ParseExact(dts, "dd/MM/yyyy", culture)).ToShortDateString(); //Convert.ToDateTime(Convert.ToDateTime(txtPostedDate.Text).ToShortDateString());
}
if (ddlCountry.SelectedIndex > 0)
countryId = Convert.ToInt32(ddlCountry.SelectedValue);
//client search from todate
if (ddlClient.SelectedIndex > 0)
clientId = Convert.ToInt32(ddlClient.SelectedValue);
if (txtFroDate.Text.Length > 0)
fDate = Convert.ToDateTime(txtFroDate.Text);
if (txtToDate.Text.Length > 0)
tDate = Convert.ToDateTime(txtToDate.Text);
Session["searchCo"] = null;
Session["searchCo"] = opName.ToString()+","+opCode+","+canName+","+emilId+","+mobile+","+notice+","+recName+","+keySkill+","+profStatus+","+postedDate+","+countryId;
if (ViewState["export"] != null )
{
//FOR EXPORT TO EXCEL
int id = 0;
var exp = gt.usp_search_profiles_client_dates101(opName, opCode == null ? 0 : opCode, canName, emilId, mobile, notice, recName, (opCode == 0 && opCode != null) ? "2" : "0", keySkill, profStatus, countryId,fDate,tDate,clientId).ToList();
var expo = (from c in exp
select new
{
Id = c.id,
CandidateName = c.candidate_name,
opening_name = c.opening_name,
Client = c.Client,
PostedDate = c.submitted_date,
Recruiter = c.submitted_by_name,
KeySkills = c.key_skills,
Exp = c.exp_years,
ContactNumber = c.contact_number,
AvailToJoin = c.notice_period,
CurrentLocation = c.current_location,
CurrentPackage = c.current_package,
OfferedPackage = c.proposed_package,
ConsultCheck = ConsultChecked(c.id),
EmpType =c.EMP_TYPE
}).ToList();
GridView1.AllowPaging = false;
CheckBox chk = (CheckBox)gvRef.HeaderRow.FindControl("chkAll");
if (chk.Checked == true)
GridView1.DataSource = expo.ToList();
else
GridView1.DataSource = expo.Where(d => d.ConsultCheck == "true").ToList();
GridView1.DataBind();
GridView1.Visible = true;
if (GridView1.Rows.Count > 0)
{
lblMsg.Text = "";
}
else
{
lblMsg.Text = "Please Select Profiles and Click again";
return;
}
//FOR EXPORT TO EXCEL
}
else
{
gvRef.DataSource = objCs.GetConsultants(opName, opCode, canName, emilId, mobile, notice, recName, keySkill, profStatus, countryId, fDate, tDate, clientId);
gvRef.DataBind();
///count
int RecordsCount = gt.usp_search_profiles_client_dates101(opName, opCode == null ? 0 : opCode, canName, emilId, mobile, notice, recName, (opCode == 0 && opCode != null) ? "2" : "0", keySkill, profStatus, countryId,fDate,tDate,clientId).ToList().Count();
lblSearchCount.Text = RecordsCount > 0 ? RecordsCount.ToString() + " Records found.." : "No Records found";
}
gt = null;
}
please asap help to me its very aurgent
Thanks & Regards
Prasad Bhagat

Ankur JainPosted Aug 6, 2014, 7:18 AM
checkout this thread...it will resolve your problem...
http://aspsnippets.com/Articles/Assign-PostBack-Trigger-Full-PostBack-for-LinkButton-inside-GridView-within-AJAX-UpdatePanel-in-ASPNet.aspx
Prasad BhagatPosted Aug 6, 2014, 6:35 AM
i added the trigger outside of gridview in the trigger section but its showing some message like
A control with ID 'lbStatus' could not be found for the trigger in UpdatePanel 'upd'.
Thanks & Regards
Prasad Bhagat
Ankur JainPosted Aug 6, 2014, 6:07 AM
i guess your gridview code is inside ajax update panel control, so link button is not firing because it is occured during Post back...
you can try this one to add it in Triggers...