Update progress control not showing image using TextChanged Event - c#

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>

Related

Unable to read RadioButton inside nested GridView

I have a nested GridView to 5 levels and I am having hard time accessing which RadioButtonList is selected in 2nd level of GridView. (first level is named gvSecondLevel so please don't get confused). I have to now access from gvThirdLevel (which is actually 2nd level grid as you will see in code). I am not sure whether the issue is with ASPX code or c# code. I have tried putting rbThirdLevel inside TemplateField and without it. But I can't access it either way. Here is the aspx code:
<table align="left">
<tr>
<td colspan="2">
<asp:GridView ID="gvSecondLevel" runat="server" AutoGenerateColumns="False" Width="800px"
ShowFooter="True" BorderStyle="none" DataKeyNames="CallCategory_ID" OnRowDataBound="gvSecondLevel_OnRowDataBound"
OnRowCommand="gvSecondLevel_RowCommand" OnRowDeleting="gv_RowDeleting" AllowPaging="true"
PageSize="10" OnPageIndexChanging="gvSecondLevel_PageIndexChanging" OnRowCreated="gvSecondLevel_RowCreated" >
<Columns>
<asp:TemplateField HeaderText="ID" HeaderStyle-Width="20px">
<ItemTemplate>
<asp:Label ID="lblBusinessID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"CallCategory_ID") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Width="20px" />
</asp:TemplateField>
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 2nd" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteSecondLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server"></asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
ItemStyle-BorderStyle="None">
<ItemTemplate>
<tr>
<td id="td_div<%# Eval("CallCategory_ID") %>" colspan="100%" style="border: none;">
<div id="div<%# Eval("CallCategory_ID") %>" style="overflow: auto; display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvThirdLevel" runat="server" Width="95%" AutoGenerateColumns="false"
ShowFooter="true" BorderStyle="none" DataKeyNames="CallCategory_ID" OnRowDataBound="gvThirdLevel_OnRowDataBound"
OnRowCommand="gvThirdLevel_RowCommand" OnRowDeleting="gv_RowDeleting">
<Columns>
<asp:TemplateField HeaderText="ID" Visible="true" HeaderStyle-Width="20px">
<ItemTemplate>
<asp:Label ID="lblCallCategoryID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CallCategory_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 3rd" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteThirdLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server">Deactivate</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
ItemStyle-BorderStyle="None">
<ItemTemplate>
<tr>
<td id="td_div1<%# Eval("CallCategory_ID") %>" colspan="100%" style="border: none;">
<div id="div1<%# Eval("CallCategory_ID") %>" style="overflow: auto; display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvFourthLevel" runat="server" Width="95%" AutoGenerateColumns="false"
BorderStyle="none" ShowFooter="true" OnRowDataBound="gvFourthLevel_OnRowDataBound"
OnRowCommand="gvFourthLevel_RowCommand" OnRowDeleting="gv_RowDeleting" DataKeyNames="CallCategory_ID">
<Columns>
<asp:TemplateField HeaderText="ID" HeaderStyle-Width="20px">
<ItemTemplate>
<asp:Label ID="lblCallCategoryID_Fourth" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CallCategory_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 4th" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteFourthLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server">Deactivate</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
ItemStyle-BorderStyle="None">
<ItemTemplate>
<tr>
<td id="td_div2<%# Eval("CallCategory_ID") %>" colspan="100%" style="border: none;">
<div id="div2<%# Eval("CallCategory_ID") %>" style="overflow: auto; display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvFifthLevel" runat="server" Width="95%" AutoGenerateColumns="false"
BorderStyle="none" ShowFooter="true" OnRowDataBound="gvFifthLevel_OnRowDataBound"
OnRowCommand="gvFifthLevel_RowCommand" OnRowDeleting="gv_RowDeleting" DataKeyNames="CallCategory_ID">
<Columns>
<asp:TemplateField HeaderText="ID" HeaderStyle-Width="20px">
<ItemTemplate>
<asp:Label ID="lblCallCategoryID_Fifth" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CallCategory_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 5th" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteFifthLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server">Deactivate</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None"
ItemStyle-BorderStyle="None">
<ItemTemplate>
<tr>
<td id="td_div3<%# Eval("CallCategory_ID") %>" colspan="100%" style="border: none;">
<div id="div3<%# Eval("CallCategory_ID") %>" style="overflow: auto; display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvSixthLevel" runat="server" Width="95%" AutoGenerateColumns="false"
BorderStyle="none" ShowFooter="true" OnRowDataBound="gvSixthLevel_OnRowDataBound"
OnRowCommand="gvSixthLevel_RowCommand" OnRowDeleting="gv_RowDeleting">
<Columns>
<asp:BoundField DataField="CallCategory_ID" HeaderText="ID" HeaderStyle-Width="20px" />
<asp:BoundField DataField="CallCategory_Name" HeaderText="Call Category Name 6th" />
<asp:TemplateField HeaderText="" ItemStyle-Width="20px">
<ItemTemplate>
<asp:LinkButton ID="lbtnDeleteSixthLevel" CommandArgument='<%# Eval("CallCategory_ID") %>'
CommandName="Delete" runat="server">Deactivate</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="rbSixthLevel" runat="server"
onselectedindexchanged="rbSixthLevel_SelectedIndexChanged" RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="rbFifthLevel" runat="server" onselectedindexchanged="rbFifthLevel_SelectedIndexChanged" RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="rbFourthLevel" runat="server" onselectedindexchanged="rbFourthLevel_SelectedIndexChanged" RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButtonList ID="rbThirdLevel" runat="server" onselectedindexchanged="rbThirdLevel_SelectedIndexChanged" RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:RadioButtonList ID="rbSecondLevel" runat="server" onselectedindexchanged="rbSecondLevel_SelectedIndexChanged"
RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem Selected="True">Active</asp:ListItem>
<asp:ListItem>Inactive</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>
C# code is just return "Active" even when I select "Inactive". Please guide what is the correct way to access rbThirdLevel
protected void rbThirdLevel_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in gvSecondLevel.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
GridView gvThirdLevel = (GridView)row.FindControl("gvThirdLevel");
if (gvThirdLevel != null)
{
RadioButtonList rbThirdLevel = gvSecondLevel.Rows[row.RowIndex].FindControl("rbThirdLevel") as RadioButtonList;
string radiovalue = (gvSecondLevel.Rows[row.RowIndex].FindControl("rbThirdLevel") as RadioButtonList).SelectedItem.Value;
if (rbThirdLevel.SelectedValue == "Inactive")
{
//code to display Deactivated rows
}
if (rbThirdLevel.SelectedValue == "Active")
{
//code to display Activated rows
}
}
}
}
}

Get modal popup values in gridview row textbox

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();
}

gridview edit mode is not getting fired on single click

I want to edit the record in gridview on single click. My gridview is placed inside update panel.
There is a search textbox given and when I type anything in search textbox "txt_Search_TextChanged" event is fired and that text is searched in database and that particular record is fetched and bind to the grid.
Now my problem is: If I click on edit button of grid without searching, then event is fired. But if I search any record and then I click on edit button, it takes 2 click to give result. I have written a script for textbox which is as follows:
enter code here
<script>
function RefreshUpdatePanel() {
__doPostBack('<%= txt_Search.ClientID %>', '');
};
below is aspx code
<table width="100%">
<tr>
<td align="center">
<div style="border-width: 2px; border-style: solid; border-color: #FDAC4C; width: 95%; border-radius: 10px;">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:GridView ID="grd_Master" ShowFooter="false" runat="server" Width="98%" AllowPaging="true" PagerStyle-CssClass="paging"
OnPageIndexChanging="grd_Master_PageIndexChanging"
PageSize="8" AutoGenerateColumns="False" BorderWidth="0" BorderStyle="Solid" BorderColor="#FDAC4C" OnRowEditing="grd_Master_RowEditing" ShowHeaderWhenEmpty="true">
<AlternatingRowStyle BackColor="#FFFFFF" Height="30px" BorderStyle="Dotted" BorderWidth="1"
BorderColor="#DDDDDD" />
<RowStyle BackColor="#FFF0DD" Height="30px" BorderStyle="Dotted" BorderWidth="1"
BorderColor="#DDDDDD" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Serial No.<br />
</HeaderTemplate>
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" Width="10%" CssClass="grdrow"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblSRNO" runat="server" Style="padding-right: 50px" Text='<%#Container.DataItemIndex+1 %>'></asp:Label>
<asp:Label ID="Cooling_Code" runat="server" Visible="false" Text='<% #Bind("Cool_Code")%>'></asp:Label>
<asp:Label ID="lblProdGrpCode" runat="server" Style="padding-left: 100px" Text='<% #Bind("Prod_Grp_Code")%>' Visible="false"></asp:Label>
<asp:Label ID="lblSubProdGrpCode" runat="server" Style="padding-left: 100px" Text='<% #Bind("Sub_Prod_Code")%>' Visible="false"></asp:Label>
<asp:Label ID="lblMakeCode" runat="server" Style="padding-left: 100px" Text='<% #Bind("Make_Code")%>' Visible="false"></asp:Label>
<asp:Label ID="lblRegerCode" runat="server" Style="padding-left: 100px" Text='<% #Bind("Refg_Code")%>' Visible="false"></asp:Label>
<asp:Label ID="lblCompressorCode" runat="server" Style="padding-left: 100px" Text='<% #Bind("Comp_Code")%>' Visible="false"></asp:Label>
<asp:Label ID="lblFilePath" runat="server" Visible="false" Style="padding-left: 100px" Text='<% #Bind("Document_Path")%>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="grdheader" Width="10%" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Cooling Name
</HeaderTemplate>
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" Width="20%" CssClass="grdrow"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblCoolingName" runat="server" Style="padding-left: 10px" Text='<% #Bind("Cool_Name")%>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="grdheader" Width="20%" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Short Name
</HeaderTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="grdheader" Width="15%"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" Width="15%" CssClass="grdrow"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblCoolingShortName" runat="server" Style="padding-left: 10px" Text='<% #Bind("Cool_Short_Name")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Cooling Description
</HeaderTemplate>
<ItemStyle HorizontalAlign="left" Width="45%" CssClass="grdrow"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblCoolingDescr" runat="server" Style="padding-left: 10px" Text='<% #Bind("Cool_Descr")%>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="grdheader" Width="45%"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Action<br />
</HeaderTemplate>
<HeaderStyle HorizontalAlign="Left" CssClass="grdheader" Width="10%"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="10%" CssClass="grdrow"></ItemStyle>
<ItemTemplate>
<asp:ImageButton ID="imgbtnEdit" runat="server" ImageUrl="~/images/Edit.png" Width="20px" ToolTip="Edit" CommandName="Edit" Height="20px" />
<asp:ImageButton ID="ImageDelete" runat="server" ImageUrl="~/images/trash1.png" ToolTip="Delete" OnClick="ImageDelete_Click" Width="25px" Height="20px" OnClientClick="return confirmDelete()" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle HorizontalAlign="Left" BorderWidth="0" BorderStyle="None" />
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txt_Search" />
<asp:PostBackTrigger ControlID="grd_Master" />
</Triggers>
</asp:UpdatePanel>
</div>
</td>
</tr>
</table>
Below is cs code for rowediting
protected void grd_Master_RowEditing(object sender, GridViewEditEventArgs e)
{
try
{
tab0.Enabled = false;
tab1.Enabled = true;
grd_Master.EditIndex = e.NewEditIndex;
GridViewRow rw = (GridViewRow)grd_Master.Rows[e.NewEditIndex];
Label CoolingCode = (Label)rw.FindControl("Cooling_Code");
Label ProdgrpCode = (Label)rw.FindControl("lblProdGrpCode");
Label SubProdCode = (Label)rw.FindControl("lblSubProdGrpCode");
Label MakeCode = (Label)rw.FindControl("lblMakeCode");
Label ReferCode = (Label)rw.FindControl("lblRegerCode");
Label CompressoreCode = (Label)rw.FindControl("lblCompressorCode");
Label CoolingName = (Label)rw.FindControl("lblCoolingName");
Label CoolingName_Short = (Label)rw.FindControl("lblCoolingShortName");
Label CoolingName_Desc = (Label)rw.FindControl("lblCoolingDescr");
Label lblFilePath = (Label)rw.FindControl("lblFilePath");
txtCoolType.Text = CoolingName.Text.Trim();
txtCoolTypeShortname.Text = CoolingName_Short.Text.Trim();
txtCoolTypeDescrip.Text = CoolingName_Desc.Text.Trim();
ddlProdGrp.SelectedValue = ProdgrpCode.Text;
ddlSubProd.SelectedValue = SubProdCode.Text;
ddlMake.SelectedValue = MakeCode.Text;
ddlCompressor.SelectedValue = CompressoreCode.Text;
ddlRefe.SelectedValue = ReferCode.Text;
btnsave.Text = "Update";
ViewState["CoolingCode"] = CoolingCode.Text;
TabContainer_Item.ActiveTabIndex = 1;
Session["CoolingCode"] = CoolingCode.Text;
this.fu1.BindGridDoc();
}
catch (Exception ex)
{
Master.ErrorMessage(ex.Message);
}
}
protected void txt_Search_TextChanged(object sender, EventArgs e)
{
try
{
DataSet ds = gn.ExecuteDataset("Search_CoolingType", txt_Search.Text.Trim());
ViewState["CoolingTypeData"] = ds.Tables[0];
if (ds.Tables[0].Rows.Count == 0)
{
FillEmptyGrid();
}
else
{
grd_Master.DataSource = ds;
grd_Master.DataBind();
}
}
catch (Exception ex)
{
Master.ErrorMessage(ex.Message);
}
}
You need to make sure that the grid has focus. The initial click is likely just setting focus on the grid, and then it sees the second click as starting your edit.
A simple ActiveControl = grd_Master; at the end of the txt_Search_TextChanged event should do the trick.

Gridview RowCommand not Fire on Server but works Locally

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.

Button action event to get row details of grid view inside repeater

I am having some problem when trying to get the rows with marked checkbox in grid view. My grid view was set up using a repeater, here is the code:
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<!-- COLLAPSIBLE PANEL EXTENDER -->
<asp:Panel ID="pHeader1" runat="server" CssClass="cpHeader">
<!-- Collapsible panel extender header -->
<div class="form-group" style="background-color: #ffb848; height: 30px; vertical-align: middle">
<div class="col-md-6">
<div style="float: left; color: White; padding: 5px 5px 0 0">
<asp:Label ID="lblProduct" Text='<%# DataBinder.Eval(Container.DataItem, "name") %>' runat="server" />
</div>
</div>
<div class="col-md-6">
<div style="float: right; color: White; padding: 5px 5px 0 0">
<asp:Label ID="lblHeaderText1" runat="server" />
</div>
</div>
<div style="clear: both"></div>
</div>
</asp:Panel>
<!-- Collapsible panel extender body -->
<asp:Panel ID="pBody1" runat="server" CssClass="cpBody">
<asp:Label ID="lblBodyText1" runat="server" />
<!-- Grid view to show products based on each category -->
<asp:GridView ID="gvProduct" runat="server" AutoGenerateColumns="False" Width="725px" CellPadding="4" ForeColor="#333333" GridLines="None" ShowHeader="False" DataKeyNames="id">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="cbCheckRow" runat="server" ItemStyle-Width="50px"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="id" HeaderText="Name" ItemStyle-Width="50px" />
<asp:BoundField DataField="name" HeaderText="Name" ItemStyle-Width="450px" />
<asp:BoundField DataField="unitQuantity" HeaderText="Unit Quantity" />
<asp:TemplateField HeaderText="Quantity" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="200px">
<ItemTemplate>
<asp:TextBox ID="tbQuantity" runat="server" Width="40" Text="0" OnTextChanged="tbQuantity_TextChanged" AutoPostBack="true"/>
<asp:Label ID="lblCheckAmount" runat="server" ForeColor="#a94442"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="cpe1" runat="server" TargetControlID="pBody1" CollapseControlID="pHeader1"
ExpandControlID="pHeader1" Collapsed="true" TextLabelID="lblHeaderText1" CollapsedText="Show"
ExpandedText="Hide" CollapsedSize="0"
ScrollContents="false">
</asp:CollapsiblePanelExtender>
</ItemTemplate>
</asp:Repeater>
What I am trying to do is, when a button is on click, it will get the datakey which is id for the rows with marked checkbox and store them into a list. So how am I supposed to write the code to loop each row of grid view to check if the check box has marked and store them into a string list?
Thanks in advance.
Let's say you want to put the DataKey values in a List<string>, then use a nested loop inside the Repeater and the GridView. The below code will collect all of the values in idList:
List<string> idList = new List<string>();
foreach (RepeaterItem ri in Repeater1.Items)
{
GridView gvProduct = (GridView)ri.FindControl("gvProduct");
foreach (GridViewRow gr in gvProduct.Rows)
{
CheckBox cb = (CheckBox)gr.FindControl("cbCheckRow");
if (cb.Checked)
{
// add the corresponding DataKey to idList
idList.Add(gvProduct.DataKeys[gr.RowIndex].Value.ToString());
}
}
}
Try this code ,
foreach (RepeaterItem i in Repeater1.Items)
{
GridView _gv = (GridView)i.FindControl("gvProduct");
foreach (GridViewRow _g in _gv.Rows)
{
CheckBox chk = (CheckBox)_g.FindControl("cbCheckRow") ;
if(chk.Checked)
{
.......
}
}
}

Categories

Resources