I have a gridview with column "View" ID= "lnkViewContact". On click of this link signup modalpopupextender will be displayed. This popup is similar for all the rows. But when I am running it the error I am getting is "Could not found control lnkViewContact". How it can be resolved. one alternative is by using Onclick event on link click but I do not want to do a postback for opening the Popupextender. Below is my code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlNoData" runat="server" align="center" Visible="false" Style="height: 300px;
width: auto;">
<h1 style="font-variant: normal; font-family: Times New Roman; font-size: 1.8em;
margin-left: 15px; font-weight: lighter; color: Green; margin-top: 100px;">
Refine your search.</h1>
<h1 style="font-variant: normal; font-family: Times New Roman; font-size: 1.8em;
margin-left: 15px; font-weight: lighter; color: Green; margin-left: 100px; margin-right: 100px;">
Not finding suitable candidates. </h1>
<cc1:ModalPopupExtender ID="mp3" runat="server" PopupControlID="pnlJobPost" BehaviorID="bvJobPost"
TargetControlID="lnkPostJobReq" BackgroundCssClass="mBackground" CancelControlID="btnClose">
</cc1:ModalPopupExtender>
<asp:LinkButton ID="lnkPostJobSignUp" Text="Sign Up and Post Job" Font-Size="Medium"
runat="server" OnClick="SignUp" Visible="false"></asp:LinkButton>
<asp:LinkButton ID="lnkPostJobReq" Text="Post Job Requirement" Font-Size="Medium"
runat="server"></asp:LinkButton>
</asp:Panel>
<asp:GridView ID="grdSearchResult" runat="server" DataKeyNames="SeekerEmail_Id, Extension"
OnRowDataBound="OnRowDataBound" AutoGenerateColumns="False" BorderWidth="1px"
BackColor="White" CellPadding="5" BorderStyle="None" BorderColor="Gray" GridLines="Both"
Width="100%">
<FooterStyle ForeColor="Black" BackColor="White"></FooterStyle>
<PagerStyle ForeColor="Black" HorizontalAlign="Center" BackColor="White"></PagerStyle>
<HeaderStyle ForeColor="White" Font-Bold="True" BackColor="Green"></HeaderStyle>
<Columns>
<asp:BoundField HeaderText="Job Skills" DataField="Primary_Skill" SortExpression="Primary_Skill"
ItemStyle-Width="35%" ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="true"
ItemStyle-CssClass="grdSearchResultbreakword"></asp:BoundField>
<asp:BoundField HeaderText="Resume Title" DataField="Resume_Title" SortExpression="Resume_Title"
ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="true" ItemStyle-Width="30%"
ItemStyle-CssClass="grdSearchResultbreakword"></asp:BoundField>
<asp:BoundField HeaderText="Exp (Years)" DataField="Experience" SortExpression="Experience"
ItemStyle-HorizontalAlign="Center"></asp:BoundField>
<asp:TemplateField HeaderText="Contact Details Email/Mobile" ItemStyle-HorizontalAlign="Center"
ItemStyle-Width="12%">
<ItemTemplate>
<asp:LinkButton ID="lnkViewContact" Text="View" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Contact Details Email/Mobile" ItemStyle-HorizontalAlign="Center"
ItemStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblContact" ForeColor="DarkOrange" runat="server" Text='<%# Eval("SeekerEmail_Id").ToString() +" / "+ Eval("Contact_Number").ToString() %>'
Style="word-wrap: normal; word-break: break-all; cursor: default;"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Download Resume" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:LinkButton ID="lnkDown" Text="Download" runat="server" OnClick="SignUp"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle ForeColor="White" Font-Bold="True" BackColor="#008A8C"></SelectedRowStyle>
<RowStyle ForeColor="Black" BackColor="White"></RowStyle>
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="mp1" BehaviorID="behaviorIDmp1" runat="server" PopupControlID="Panl1"
TargetControlID="lnkViewContact" CancelControlID="btnCancel" DropShadow="true" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panl1" runat="server" CssClass="modalPopup" align="center" Style="display: none;
height: 400px;" DefaultButton="btnRegister">
<%--<h1 style="font-variant: normal; font-family: Comic Sans MS; font-size: 1.5em; font-weight: lighter;
margin-top: 2px; margin-bottom: 2px; text-align: center; color: Blue;">
SIGN UP</h1>--%>
<asp:Label ID="lblEmailId" runat="server" ForeColor="Black" Text="Email address"
Style="font-weight: bold; display: block; text-align: left; margin-left: 45px;
margin-top: 10px;"></asp:Label>
<asp:TextBox ID="txtEmailAddress" runat="server" class="txtFirstName" MaxLength="100"
name="email" TabIndex="3" value="" /><br />
<asp:RequiredFieldValidator EnableClientScript="true" ID="reqEmailAdress" runat="server"
ValidationGroup="modal" ControlToValidate="txtEmailAddress" ErrorMessage="Email Address Required"
Display="Dynamic" Style="color: Red;" />
<asp:RegularExpressionValidator ID="regEmailAddress" runat="server" ErrorMessage="Not Valid Email ID"
ValidationGroup="modal" Display="Dynamic" ControlToValidate="txtEmailAddress"
ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator>
<asp:Label ID="lblContactNumber" runat="server" ForeColor="Black" Text="Contact Number(Don't prefix 0 or +91)"
Style="font-weight: bold; display: block; text-align: left; margin-left: 45px;"></asp:Label>
<asp:TextBox ID="txtContactNumber" runat="server" class="txtFirstName" MaxLength="15"
name="contact" TabIndex="6" value="" /><br />
<asp:RequiredFieldValidator EnableClientScript="true" ID="reqContactNumber" runat="server"
ValidationGroup="modal" ControlToValidate="txtContactNumber" ErrorMessage="Contact Number Required"
Display="Dynamic" Style="color: Red;" />
<asp:RegularExpressionValidator ID="regContactNumber" runat="server" ControlToValidate="txtContactNumber"
ValidationGroup="modal" Text="Only 10 digit valid contact number is valid." ValidationExpression="[0-9]{10}"
Style="color: Red;" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:Button ID="btnRegister" ValidationGroup="modal" class="btnempregsubmit" runat="server"
Text="Save" OnClick="Register" CausesValidation="false" />
<br />
<asp:HyperLink ID="btnCancel" runat="server" Text="Cancel" CssClass="btnClosePopup">Close</asp:HyperLink>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="grdSearchResult" />
<asp:AsyncPostBackTrigger ControlID="btnRegister" />
</Triggers>
</asp:UpdatePanel>
It is a bit confusing when you mentioned 'one alternative is by using Onclick event on link click but I do not want to do a postback for opening the Popupextender. ' If you want an OnClick event, you will have to make postback. Below is a suggestion.
.....This part is your code....
<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="mp1" BehaviorID="behaviorIDmp1" runat="server" PopupControlID="Panl1"
TargetControlID="lnkViewContact" CancelControlID="btnCancel" DropShadow="true" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
....Replace with this......
<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="mp1" BehaviorID="behaviorIDmp1" runat="server" PopupControlID="Panl1"
TargetControlID="lnkFake" CancelControlID="btnCancel" DropShadow="true" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
And on the OnClick event code behind, do this to show the pop up
mp1.Show()
The Linkbutton inside a Gridview cannot be set as a TargetcontrolID of Modalpopupextender because at run time the ID of linkbutton will change dynaically. The work around is use the Onclick event of LinkButton and like in my case if there is any validation in modalpopupextender then validate the controls on server side.
Related
I have a gridview with dynamic controls. Resource name is something that I am picking up from Active directory. Search filter works in a way where you have to enter lastname, firstname and onlclick of lookup it will search. If there are more than one record a modalpopup will be displayed with dropdownlist with options to select from.
The issue is that I am unable to get the dropdown values populated into textbox present in gridview. I need this dropdown value in correct selected row's textbox.
Code behind:
protected void gvProjectResource_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Lookup")
{
GridViewRow clickedRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow;
TextBox t2 = ((TextBox)clickedRow.FindControl("t2"));
DataTable dt = globalObj.FindPersons(t2.Text.Split(',')[0].Trim(), t2.Text.Split(',')[1].Trim());
if (dt.Rows.Count > 1)
{
mpFindPerson.Show();
ddlPersons.Items.Clear();
ddlPersons.Items.Add(new ListItem { Value = "0", Text = "-Select User-" });
ddlPersons.DataSource = dt;
dt.Columns.Add("FullName", typeof(string), "DisplayName + ' | ' + MSID");
ddlPersons.DataTextField = "FullName";
ddlPersons.DataValueField = "MSID";
ddlPersons.DataBind();
}
else
{
t2.Text = dt.Rows[0].ItemArray[0].ToString();
}
}
if (e.CommandName == "Del")
{
}
}
protected void btnSelectPerson_Click(object sender, EventArgs e)
{
TextBox t2 = (gvProjectResource.SelectedRow.FindControl("t2") as TextBox);
t2.Text = ddlPersons.SelectedItem.Text;
mpFindPerson.Hide();
}
ASPX Code:
<div id="four">
<fieldset style="border: solid; border-width: thin; height: 220px; border-color: #a8a8a8;">
<legend id="Legend11" runat="server" visible="true" style="width: auto; margin-bottom: 0px; font-size: 12px; font-weight: bold; color: #1f497d;"> Project Resources </legend>
<div style="height: 210px; overflow: auto;">
<asp:GridView ID="gvProjectResource" Width="88%" HeaderStyle-Font-Size="X-Small" CssClass="labels" runat="server"
ShowFooter="true" AutoGenerateColumns="false" Style="margin-right: auto; margin-left:7px;"
OnRowDataBound="gvProjectResource_RowDataBound"
OnRowCommand="gvProjectResource_RowCommand" >
<Columns>
<asp:TemplateField HeaderText="Role" ItemStyle-VerticalAlign="Top" FooterStyle-VerticalAlign="Top" ItemStyle-Width="50%">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text='<%# Eval("role") %>' Visible="false" />
<asp:DropDownList ID="ddlRole" Height="23px" Width="98%" runat="server" CssClass="DropDownListStyleOverview"></asp:DropDownList>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlRole2" Height="23px" Width="98%" runat="server" CssClass="DropDownListStyleOverview"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Resource Name" ItemStyle-VerticalAlign="Top" FooterStyle-VerticalAlign="Top" ItemStyle-Width="50%">
<ItemTemplate>
<asp:TextBox ID="t1" Height="23px" Width="98%" runat="server" ></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="t2" Height="23px" Width="68%" runat="server"></asp:TextBox>
<asp:LinkButton runat="server" Text="Lookup" CommandName="Lookup" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Top" ItemStyle-Width="5%">
<ItemTemplate>
<asp:LinkButton runat="server" Text="Delete" CommandName="Del" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<div style="text-align: right;">
<asp:LinkButton runat="server" Text="Add New" ID="LinkButton2" CssClass="labels"></asp:LinkButton>
</div>
</div>
<asp:Button runat="server" ID="btnModalPopUpSearch" Style="display: none" />
<AjaxToolkit:ModalPopupExtender ID="mpFindPerson"
BehaviorID="mpFindPersonBehav"
runat="server"
DropShadow="true"
BackgroundCssClass="modalBackground"
PopupControlID="pnlFindPerson"
TargetControlID="btnModalPopUpSearch">
</AjaxToolkit:ModalPopupExtender>
<asp:Panel runat="Server" ID="pnlFindPerson" CssClass="modalPopup" style="position:relative;">
<div class="labels" runat="server" style="text-align:center; position:absolute; top:20%; height:10em; margin-top:auto; margin-left:20px;">
<asp:DropDownList ID="ddlPersons" runat="server" AppendDataBoundItems="true" Width="200px">
<asp:ListItem Text="-Select User-" Value="0" />
</asp:DropDownList>
<br />
<br />
<br />
<div style="text-align: center;">
<asp:Button runat="server" Font-Size="9pt" Text="Select" CssClass="buttons___" Style="float: left;"
ID="btnSelectPerson" OnClick="btnSelectPerson_Click" />
</div>
</div>
</asp:Panel>
</fieldset>
</div>
ok, so, there was nothing much to do.
have to add this.
protected void btnSelectPerson_Click(object sender, EventArgs e)
{
TextBox t2 = (TextBox)gvProjectResource.FooterRow.FindControl("t2");
t2.Text = ddlPersons.SelectedItem.Text;
mpFindPerson.Hide();
}
I want to show Loading image while TextChanged Event because I am filling gridview while TextChanged Event change. I am trying but image is not showing.
Below is my design code:
<asp:Panel ID="pnl_Candidate" runat="server" Visible="false">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txt_CandidateSource" runat="server" OnTextChanged="txt_CandidateSource_TextChanged" AutoPostBack="True" class="form-control input-sm" placeholder="Candidate Source" Width="30%" />
<asp:GridView ID="GridView1" runat="server" CssClass="footable" Style="max-width: 500px" AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging" AllowPaging="true" PageSize="5" DataKeyNames="EMail" >
<Columns>
<asp:TemplateField HeaderText="Sno">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CandidateSource" HeaderText="CandidateSource"></asp:BoundField>
<asp:BoundField DataField="Name" HeaderText="Name"></asp:BoundField>
<asp:BoundField DataField="Gender" HeaderText="Gender"></asp:BoundField>
<asp:BoundField DataField="DOB" HeaderText="DOB"></asp:BoundField>
<asp:BoundField DataField="Mobile" HeaderText="Mobile"></asp:BoundField>
<asp:BoundField DataField="EMail" HeaderText="EMail"></asp:BoundField>
<asp:BoundField DataField="Qualification" HeaderText="Qualification"></asp:BoundField>
<asp:BoundField DataField="CurrentLocation" HeaderText="CurrentLocation"></asp:BoundField>
<asp:BoundField DataField="TotalExperience" HeaderText="TotalExperience"></asp:BoundField>
<asp:BoundField DataField="CurrentCompany" HeaderText="CurrentCompany"></asp:BoundField>
<asp:BoundField DataField="Designation" HeaderText="Designation"></asp:BoundField>
<asp:BoundField DataField="WorkLocation" HeaderText="WorkLocation"></asp:BoundField>
<asp:TemplateField HeaderText="add Comment Status">
<ItemTemplate>
<asp:LinkButton ID="lnkbtn_Comment_Status" runat="server"
Text="Comment" OnClick="lnkbtn_Comment_Status_Click"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pgr" />
<EmptyDataTemplate>
<center>
<asp:Label ID="Label2" CssClass="Helptext_red" runat="server" Text="No Candidate Available"></asp:Label>
</center>
</EmptyDataTemplate>
<HeaderStyle CssClass="header" />
<AlternatingRowStyle CssClass="alt" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" DisplayAfter="0" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="modal">
<div class="center">
<img alt="" src="loading_bar_animated.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
My TextChange Event and Filling gridview in every text change event:
protected void txt_CandidateSource_TextChanged(object sender, EventArgs e)
{
if (txt_CandidateSource.Text != "")
{
System.Threading.Thread.Sleep(2000);
DataTable dt = new DataTable();
bo.Para1 = txt_CandidateSource.Text;
bo.Para2 = txt_Qualification.Text;
bo.Para3 = txt_CurrentLocation.Text;
bo.Para4 = txt_TotalExperience.Text;
bo.Para5 = txt_Designation.Text;
dt = bl.Search_CandidateMaster(bo);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
use this UpdateProgress fine work
CSS:
<style type="text/css">
.rcs {
display: block;
position: absolute;
top: 40%;
left: 45%;
}
</style>
ASPX:
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="1" DynamicLayout="true">
<ProgressTemplate>
<asp:Panel ID="Panel1543633" runat="server" Style="width: 100%; height: 100%; position: fixed; left: 0; top: 0; z-index: 99999; background: rgba(0, 0, 0, 0.2);">
<div class="rcs">
<asp:Image ID="Image1" ImageUrl="~/images/loading.gif" AlternateText="Processing"
runat="server" />
</div>
</asp:Panel>
</ProgressTemplate>
</asp:UpdateProgress>
Hi I have an asp updatePanel which contains several asp panels. The way it should function is you click the button in the first panel it hides that panel and shows the next. That works fine the problem comes with the next panel. If I try and use either of the button controls within that panel nothing happens.
Heres the html
<asp:UpdatePanel runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Panel ID="pnlAppRej" runat="server" HorizontalAlign="Center" CssClass="textBox"
Width="85%" Visible="True">
<div style="text-align:left; width:90%">
<asp:Label ID="lblAppRej" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" Style="margin-right: 20px;
margin-top: 10px" Width="100px" onclick="btnApprove_Click" />
<asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" Style="margin-left: 20px"
Width="100px" onclick="btnReject_Click" />
</asp:Panel>
<asp:Panel runat="server" ID="pnlRejCom" Width="85%" Visible="False" CssClass="textBox">
<div style="text-align: left">
Comments<br />
</div>
<asp:TextBox ID="tbRejCom" runat="server" Height="54px" TextMode="MultiLine" Width="95%"
CssClass="textBox" Style="margin-top: 5px" ValidationGroup="rejCom"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbRejCom"
ErrorMessage="RequiredFieldValidator" ValidationGroup="rejCom">*</asp:RequiredFieldValidator>
<br />
<div style="text-align: center">
<asp:Button ID="btnBackRejCom" runat="server" CssClass="button" Text="Back" Style="margin-right: 20px;
margin-top: 10px" Width="100px" />
<asp:Button ID="btnDoneRejCom" runat="server" CssClass="button" Text="Done" Style="margin-left: 20px;
margin-top: 10px" Width="100px" ValidationGroup="rejCom"
onclick="btnDoneRejCom_Click" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
c# code
protected void btnReject_Click(object sender, EventArgs e)
{
pnlRejCom.Visible = true;
pnlAppRej.Visible = false;
}
protected void btnBackRejCom_Click(object sender, EventArgs e)
{
pnlRejCom.Visible = false;
pnlAppRej.Visible = true;
}
its the btnBackRejCom_Click method which doesnt seem to fire. But I have tested setting the pnlRejCom to visible and the method works fine.
Thanks in advance
Charlie
your problem seems to be different.
I would suggest, delete the
protected void btnBackRejCom_Click(object sender, EventArgs e){}
and again create a new event.
This is what i tried and is working fine now.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnReject" />
<asp:AsyncPostBackTrigger ControlID="btnBackRejCom" />
<asp:PostBackTrigger ControlID="btnDoneRejCom" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlAppRej" runat="server" HorizontalAlign="Center" CssClass="textBox"
Width="85%" Visible="True">
<div style="text-align: left; width: 90%">
<asp:Label ID="lblAppRej" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" Style="margin-right: 20px; margin-top: 10px"
Width="100px" OnClick="btnApprove_Click" />
<asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" Style="margin-left: 20px"
Width="100px" OnClick="btnReject_Click" />
</asp:Panel>
<asp:Panel runat="server" ID="pnlRejCom" Width="85%" Visible="False" CssClass="textBox">
<div style="text-align: left">
Comments<br />
</div>
<asp:TextBox ID="tbRejCom" runat="server" Height="54px" TextMode="MultiLine" Width="95%"
CssClass="textBox" Style="margin-top: 5px" ValidationGroup="rejCom"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbRejCom"
ErrorMessage="RequiredFieldValidator" ValidationGroup="rejCom">*</asp:RequiredFieldValidator>
<br />
<div style="text-align: center">
<asp:Button ID="btnBackRejCom" runat="server" CssClass="button" Text="Back" Style="margin-right: 20px; margin-top: 10px"
Width="100px" OnClick="btnBackRejCom_Click1" />
<asp:Button ID="btnDoneRejCom" runat="server" CssClass="button" Text="Done" Style="margin-left: 20px; margin-top: 10px"
Width="100px" ValidationGroup="rejCom"
OnClick="btnDoneRejCom_Click" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
code behind :
protected void btnBackRejCom_Click1(object sender, EventArgs e)
{
pnlRejCom.Visible = false;
pnlAppRej.Visible = true;
}
Hope this helps. Happy Coding..!!!
I have same problem so I have just added CausesValidation="False" then it works fine for me.so please add CausesValidation in btnBackRejCom button like as below
Please try it
<asp:Button ID="btnBackRejCom" runat="server" CausesValidation="False" CssClass="button" Text="Back" Style="margin-right: 20px;
margin-top: 10px" Width="100px" />
I think It works for you :)
Gridview RowCommand not fire on server but when i use it on local system it works.But when i publish and post to server RowCommand not fired..shall u give me an solution for this...This is my Grid view Code.
Aspx code:
<asp:GridView ID="gvCandiList" runat="server" Style="border: 1px;" RowStyle-BorderColor="#ebf3e4"ViewStateMode="Enabled" RowStyle-BorderStyle="None" GridLines="Both" PageSize="10" AllowPaging="true" AutoGenerateColumns="false" Width="100%" AlternatingRowStyle-BackColor="" CssClass="grdCandList" RowStyle-CssClass="RowStyle" AlternatingRowStyle-CssClass="AltRowStyle" HeaderStyle-CssClass="grdheaderCandList"
DataKeyNames="UserId" OnPageIndexChanging="gvCandiList_PageIndexChanging" OnRowCommand="gvCandiList_RowCommand"OnRowDataBound="gvCandiList_RowDataBound" AllowSorting="true" OnSorting="gvCandiList_Sorting">
<EmptyDataTemplate>
<div class="shadowbox" style="min-height: 75px;">
<br />
<center>
No Data Found.</center>
</div>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="Name" ItemStyle-CssClass="grdcolumncenter" HeaderStyle-CssClass="grdcolumnheadermiddle pad_left5 pad_right5 NameHeaderWidth"
SortExpression="CandiName">
<ItemTemplate>
<h4 style="font-size: 13px; text-align: left; font-weight: normal !important; color: rgb(67, 73, 75);font-family: Calibri;">
<asp:LinkButtonID="lnkCandidateView" runat="server" Style="text-decoration: none;
color: rgb(67, 73, 75);" onmouseover='mouseover(this);' onmouseout='mouseout(this);' CommandName="View" CommandArgument='<%# Eval("CandidateId")%>'>
<asp:Label ToolTip='<%# Eval("CandiName")%>' ID="lblGrdCandiName" runat="server"Text='<%# Eval("CandiName")%>'></asp:Label></asp:LinkButton></h4>
<asp:ImageButton ID="ImageButton1" runat="server" Visible="false" ImageUrl="~/Images/edit.png"CommandName="Modi" CommandArgument='<%# Eval("UserId")%>' ToolTip="Edit" />
<asp:ImageButton ID="ImageButton2" runat="server" ToolTip="View" Visible="false"
ImageUrl="~/Images/view.png" CommandName="View" CommandArgument='<%# Eval("UserId")%>' />
<asp:ImageButton ID="ImageButton3" runat="server" ToolTip="Delete" Visible="false" ImageUrl="~/Images/delete.png" CommandName="Del" CommandArgument='<%# Eval("UserId")%>'
OnClientClick="return confirm('Are you sure ?');" />
<div style="float: left;">
<asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:ImageButton ID="imgbtnNewCmnt" runat="server" Visible="false" CommandName="NewCmnt" CommandArgument='<%# Eval("CandidateId")%>' ToolTip="New Comment" ImageUrl="~/Images/reminder.png" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
ASPX.CS
protected void gvCandiList_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("View"))
{
Session["CandiUserId"] = e.CommandArgument.ToString();
DisplayCandidateDetails();
}
}
content is not allowed between opening and closing tags for element "Button"
So replace your lnkCandidateView button with
<asp:Button ID="lnkCandidateView" ToolTip='<%# Eval("CandiName")%>' Text='<%# Eval("CandiName")%>'
runat="server" Style="text-decoration: none; color: rgb(67, 73, 75);" onmouseover='mouseover(this);'
onmouseout='mouseout(this);' CommandName="View" CommandArgument='<%# Eval("CandidateId")%>' />
Seems like a viewState Issue. One solution is to set the EnableViewState property of GridView to true.
You have set ViewStateMode="Enabled" , so Not sure what's the final setting your GridView is inheriting.May be the ContentPlaceHolder of the masterpage has viewstate
turned off. Try turning it on.
How do I access a control in a grid view so that I can change it's forecolor? In this code below, FindControl() returns null.
protected void mileageRowBound(object sender, GridViewRowEventArgs e)
{
(e.Row.Cells[1].FindControl("ddlStateCode") as DropDownList).ForeColor = System.Drawing.Color.LightBlue;
}
I have also tried e.Row.FindControl("ddlStateCode") and a few other variations. I'm stumped.
Someone asked for the markup:
<asp:GridView runat="server" OnPreRender="grvStateWiseMileage_OnPreRender" OnRowCommand="grvStateWiseMileage_OnRowCommand"
CssClass="GridViewStyle" BorderWidth="1" Width="100%" ID="grvStateWiseMileage"
AutoGenerateColumns="false" RowStyle-Height="25px" ShowHeader="false" OnRowDataBound="mileageRowBound">
<Columns>
<asp:TemplateField>
<ItemStyle CssClass="GridViewRowStyle" Width="5%" />
<ItemTemplate>
<asp:Label ID="lblLine" runat="server" onKeyUp="javascript:ValidateDecimal(this)"
Text='<%# Eval("Line#") %>'></asp:Label>
<asp:ImageButton runat="server" ID="imgbtnMileageDelete" ImageUrl="Images/delete.png" />
<asp:HiddenField runat="server" ID="hdnFuelMileageCode" Value='<% #Eval("FuelMileageCode") %>' />
<asp:HiddenField runat="server" ID="hdnMileageCode" Value='<% # Eval("MileageCode") %>' />
<asp:HiddenField runat="server" ID="hdnMileagePosted" Value='<% # Eval("MileagePosted") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle CssClass="GridViewRowStyle" Width="10%" />
<ItemTemplate>
<asp:DropDownList runat="server" OnLoad="ddlStateCode_OnLoad" ID="ddlStateCode" Style="border: none;
border-width: 0px; width: 100px">
</asp:DropDownList>
<asp:HiddenField runat="server" ID="hdnStateCode" Value='<% # Eval("State")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle CssClass="GridViewRowStyle" Width="10%" />
<ItemTemplate>
<BDP:BasicDatePicker ID="bdpMileageDate" runat="server">
</BDP:BasicDatePicker>
<asp:HiddenField runat="server" ID="hdnMileageDate" Value='<% # Eval("Date")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle CssClass="GridViewRowStyle" Width="10%" />
<ItemTemplate>
<asp:TextBox ID="txtMiles" Style="border: none; border-width: 0px; text-align: right"
Width="90%" runat="server" MaxLength="12" onKeyUp="javascript:ValidateDecimal(this)"
Text='<%# Eval("Miles") %>' onblur="postBackHiddenField('hdnStateWiseMileage')"
onkeydown="return postBackHiddenFieldForEnterMiles(event)"></asp:TextBox>
<cc1:FilteredTextBoxExtender runat="server" FilterMode="ValidChars" FilterType="Custom, Numbers"
ValidChars="." TargetControlID="txtMiles">
</cc1:FilteredTextBoxExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle CssClass="GridViewRowStyle" Width="10%" />
<ItemTemplate>
<asp:DropDownList runat="server" ID="ddlLoadStatus" Style="border: none; border-width: 0px;
width: 100px">
<asp:ListItem Selected="True" Text="Loaded" Value="1"></asp:ListItem>
<asp:ListItem Text="Empty" Value="2"></asp:ListItem>
<asp:ListItem Text="Toll" Value="3"></asp:ListItem>
</asp:DropDownList>
<asp:HiddenField runat="server" ID="hdnMileageType" Value='<% # Eval("LoadStatus")%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BorderStyle="None" BackColor="White" />
</asp:GridView>
Try to wrap your line of code in
if(e.Row.RowType == DataControlRowType.DataRow)
{
(e.Row.FindControl("ddlStateCode") as DropDownList).ForeColor = System.Drawing.Color.LightBlue;
}
So it will skip header (and footer and a few others).
I guess the better answer to this question is use CSS to change the color of the control text.
Try add the following lines to the ASPX page.
<style type="text/css">
#ddlStateCode
{
color: #FF0000; /* Change to the hexacode you want */
}
</style>
Hope it helps.