Friday, January 28, 2011

Modal popup using ajax for gridview

<script runat="server">protected void btndetails_Click(object sender, EventArgs e)
{
Button btnviewdetails = sender as Button;
GridViewRow row = (GridViewRow)btnviewdetails.NamingContainer;
this.sqldsprofiledetails.SelectParameters.Clear();
string ID =Convert.ToString(this.GVprofiledetails.DataKeys[row.RowIndex].Value);
this.sqldsprofiledetails.SelectParameters.Add("ID", ID);
this.dvProfileDetails.DataSource = this.sqldsprofiledetails;
this.dvProfileDetails.DataBind();
this.dvProfileDetails.Fields[0].Visible = false;

this.MPE.Show();
}

</script>

//Toolscript manager and sql datasource for popup
<asp:ToolkitScriptManager ID="TSM" runat="server"></asp:ToolkitScriptManager><asp:SqlDataSource ID="sqldsgriddetails" runat="server" SelectCommand="select ID,Name,ExpInYrs,CurrentCompany,CurrentSalaryInLacs,CurrentDesignation,CurrentLocation from dbo.tblCandidateProfile"SelectCommandType="Text" ConnectionString="server=CAMJ82R4BS\SQLEXPRESS;database=CMI_CVBank;User ID=CVBankUser;password=CVBankUser;"></asp:SqlDataSource><asp:SqlDataSource ID="sqldsprofiledetails" runat="server" SelectCommand="select ID,Name,Source,ReferredBy,Description,ExpInYrs,CurrentSalaryInLacs,CurrentLocation,WillingToRelocate,FileName from dbo.tblCandidateProfile where ID=@ID"SelectCommandType="Text" CancelSelectOnNullParameter="true" ConnectionString="server=CAMJ82R4BS\SQLEXPRESS;database=CMI_CVBank;User ID=CVBankUser;password=CVBankUser;"></asp:SqlDataSource>

//Proxy button and detailsview inside the popup panel
<asp:Button ID="btnshowpopup" runat="server" CssClass="buttonpopup"/><asp:ModalPopupExtender ID="MPE" runat="server" TargetControlID="btnshowpopup" PopupControlID="pnlpopupcontent"CancelControlID="btnCancel" BackgroundCssClass="modalBackground" ></asp:ModalPopupExtender>
<asp:Panel ID="pnlpopupcontent" runat="server" Width="100%"><asp:UpdatePanel ID="updpnlprofiledetails" runat="server" UpdateMode="Conditional"><ContentTemplate><div align="center" style="width: 200"><asp:Label ID="lblCandidateDetail" runat="server" Text="Candidate Details" Font-Bold="True" Font-Size="XX-Large" ForeColor="Black"></asp:Label></div><asp:DetailsView ID="dvProfileDetails" runat="server" DefaultMode="ReadOnly" Width="561px"Height="193px" BackColor="white" HorizontalAlign="Center"
BorderColor="Black" BorderStyle="Solid"
CellPadding="4" CellSpacing="4" Font-Bold="True" OnDataBound="dvProfileDetails_DataBound"
GridLines="None" DataKeyNames="ID" AutoGenerateRows="false"
HeaderStyle-Font-Bold="true" ><Fields>
<asp:BoundField DataField="ID" HeaderText="ID" /><asp:BoundField DataField="Name" HeaderText="Name" /><asp:BoundField DataField="Source" HeaderText="Source" /><asp:BoundField DataField="ReferredBy" HeaderText="Referred By" /><asp:BoundField DataField="Description" HeaderText="Description" /><asp:TemplateField HeaderText="Skill Sets"><ItemTemplate><asp:Label ID="lblSkills" runat="server" ></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Qualification"><ItemTemplate ><asp:Label ID="blQualification" runat="server"></asp:Label></ItemTemplate></asp:TemplateField><asp:BoundField DataField="ExpInYrs" HeaderText="Experince in years" /><asp:BoundField DataField="CurrentSalaryInLacs" HeaderText="Current Annual salary in lacs" /><asp:BoundField DataField="CurrentLocation" HeaderText="Current Location" /><asp:TemplateField HeaderText="Willing To Relocate"><ItemTemplate ><asp:Label ID="lblRelocate" runat="server" ></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="HR Remarks">
<ItemTemplate>
<asp:TextBox ID="txtoldhrremarks" runat="server" TextMode="MultiLine" ReadOnly="true"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="HR Remarks (if any new remarks)">
<ItemTemplate>
<asp:TextBox ID="txthrremarks" Text="" runat="server" TextMode="MultiLine"></asp:TextBox></ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField DataTextField="FileName" DataNavigateUrlFields="FileName" DataNavigateUrlFormatString="/resumes/{0}" HeaderText="Download full profile" />
<asp:TemplateField></asp:TemplateField></Fields>
<HeaderStyle Font-Bold="True" /></asp:DetailsView>

No comments:

Post a Comment