Click here to Skip to main content
15,906,097 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a job list on gridview. when user click apply image button then apply panel is displayed...that collects user information with resume on fileupload then again he need to click apply button for apply to that job.....I am collect that information from apply panel ..but i cant have the resume from apply panel...How can i do that.....


Aspx page:

<asp:GridView ID="GridView1" GridLines="None" BorderStyle="None" runat="server" Width="100%" AutoGenerateColumns="False"
onpageindexchanging="GridView1_PageIndexChanging" AllowPaging="True" PageSize="20" OnRowCommand="GridView1_RowCommand" >
<columns>
<asp:TemplateField ControlStyle-BorderStyle="None">
<itemtemplate>


<%# Eval("Walkin_Title") %>--Exp.[<%#Eval("Exp")%>]
<%#Eval("Company_Name")%>
Skills :<%#Eval("Skills")%>



<asp:Panel ID="ApplyPanel" runat="server" Visible="false" >
Job Location :<%# Eval("LocationName")%> <asp:ImageButton ID="ImageButton1" OnClick="ImageButton1_Click" CommandArgument='<%# Eval("WalkinID")%>' ImageUrl="~/images/apply.png" runat="server" />
<asp:Label ID="maillbl" runat="server" Visible="false" Text='<%# Eval("ContactMail")%>' >
<asp:Label ID="resltlbl" runat="server" Text="Label" Visible="False" CssClass="Confirm_Msg">

  Apply for this job 
<asp:Image ID="Image2" runat="server" Height="25px" ImageAlign="AbsMiddle"
ImageUrl="~/images/AboveArrow.jpg" Width="25px" />
  <asp:ValidationSummary ID="ValidationSummary1" runat="server"
ValidationGroup="ApplyCheck" />
valign="middle">
*
Your Name <asp:TextBox ID="NameTxtbx" runat="server" Width="180px">


<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="NameTxtbx" Display="None" ErrorMessage="Enter Name!"
SetFocusOnError="True" ValidationGroup="ApplyCheck">
* Your Email-ID <asp:TextBox ID="EmailTxtbx" runat="server" Width="180px">


<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="EmailTxtbx" Display="None" ErrorMessage="Enter Email-ID!"
SetFocusOnError="True" ValidationGroup="ApplyCheck">
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ErrorMessage="Enter Valid Mail ID!" ControlToValidate="EmailTxtbx"
Display="None" SetFocusOnError="True" ValidationGroup="ApplyCheck">
  Your Mobile Number <asp:TextBox ID="MobileTxtbx" runat="server" MaxLength="13" Width="180px">


<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="MobileTxtbx" Display="None" ValidationExpression="^\d+$"
ErrorMessage="Enter Valid Mobile Number!" SetFocusOnError="True"
ValidationGroup="ApplyCheck">
* Attach your Resume <asp:FileUpload ID="FileUpload1" runat="server" Width="180px" />


<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ValidationExpression="^.*\.(doc|DOC|pdf|PDF|DOCX|docx|txt|TXT)$"
ErrorMessage="Upload Valid Document!" ControlToValidate="FileUpload1"
Display="None" SetFocusOnError="True" ValidationGroup="ApplyCheck">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="FileUpload1" Display="None"
ErrorMessage="Upload your Resume!" SetFocusOnError="True"
ValidationGroup="ApplyCheck">
  Message
  <asp:TextBox ID="MsgTxtbx" runat="server" Height="150px" TextMode="MultiLine"
Width="75%">
  <asp:Button ID="ApplyBtn" runat="server" Text="Apply" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
Width="100px" CommandName="register" ValidationGroup="ApplyCheck" />







<pagersettings firstpagetext="" lastpagetext="">
Mode="NextPreviousFirstLast" NextPageText=""
PreviousPageText="Previous" FirstPageImageUrl="~/images/First_arrow.png"
LastPageImageUrl="~/images/Last_Arrow.png"
NextPageImageUrl="~/images/Next_arrow.png"
PreviousPageImageUrl="~/images/previous_arrow.png" />
<pagerstyle horizontalalign="Center" verticalalign="Bottom">




Aspx.cs :

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{

if (e.CommandName == "register")
{
Random _r = new Random();

int index = Convert.ToInt32(e.CommandArgument.ToString());
TextBox New_NameTxtbx = (TextBox)GridView1.Rows[index].FindControl("NameTxtbx");
TextBox New_EmailTxtbx = (TextBox)GridView1.Rows[index].FindControl("EmailTxtbx");
TextBox New_MobileTxtbx = (TextBox)GridView1.Rows[index].FindControl("MobileTxtbx");
TextBox New_MsgTxtbx = (TextBox)GridView1.Rows[index].FindControl("MsgTxtbx");
Label New_resltlbl = (Label)GridView1.Rows[index].FindControl("resltlbl");
FileUpload Nw_FileUpload1 = (FileUpload)GridView1.Rows[index].FindControl("FileUpload1") as FileUpload;

string name = New_NameTxtbx.Text;
string email = New_EmailTxtbx.Text;
string mobile = New_MobileTxtbx.Text;
string msg = New_MsgTxtbx.Text;



string exe = Path.GetExtension(Nw_FileUpload1.PostedFile.FileName.ToString());

string resumeend = DateTime.Now.ToString().Replace(":", "").Replace(" ", "").Replace("/", "").Replace("AM", "").Replace("PM", "") + exe;
int n = _r.Next(5);
string resumename = n + name + resumeend;

Nw_FileUpload1.SaveAs(Server.MapPath("Resumes/" + resumename));

int val = Objwalkin.Add_AppliedJob(Convert.ToInt32(Session["JobId"]), name, email, msg, resumename, mobile);

if (val > 0)
{

New_resltlbl.Visible = true;
New_resltlbl.Text = "Applied Successfully!";

Panel NewApplyPanel = (Panel)GridView1.Rows[index].FindControl("ApplyPanel");
NewApplyPanel.Visible = false;

New_MobileTxtbx.Text = "";
New_EmailTxtbx.Text = "";
New_MsgTxtbx.Text = "";
New_NameTxtbx.Text = "";

}
else
{
New_resltlbl.Visible = true;
New_resltlbl.Text = "U R Already Applied for this Job!";

Panel NewApplyPanel = (Panel)GridView1.Rows[index].FindControl("ApplyPanel");
NewApplyPanel.Visible = false;

New_MobileTxtbx.Text = "";
New_EmailTxtbx.Text = "";
New_MsgTxtbx.Text = "";
New_NameTxtbx.Text = "";
}
}
}

protected void ImageButton1_Click(object sender, EventArgs e)
{
ImageButton ib = (ImageButton)sender;
Session["JobId"] = int.Parse(ib.CommandArgument);

GridViewRow Gvr = (GridViewRow)ib.NamingContainer;

Panel NewApplyPanel = (Panel)Gvr.FindControl("ApplyPanel");

if ( NewApplyPanel.Visible == true )
{
NewApplyPanel.Visible = false;
}
else
{
NewApplyPanel.Visible = true;

}
}
Posted
Comments
JoCodes 20-Sep-13 2:16am    
Are able to upload the Resume from the Apply panel successfully ? Also please specify the errors you are getting if any?
SnvMohan 20-Sep-13 2:47am    
yes....There is no problem in upload file in control...Problem araised when i try to get the extension of a file on upload control
Thanks7872 20-Sep-13 2:19am    
Post smallest possible code here. You have thrown such a code dump that even changed design of cp. Format your code dump to some extent.
JoCodes 20-Sep-13 3:07am    
Yes , the code is not at all readable
SnvMohan 20-Sep-13 3:16am    
Then how can i get that?

1 solution

Simply put fileupload control and then find control in your c# page. like when you click on Apply button first time, you need to show pop up with applying features required, once user will click again on Apply button, save values of your file in database and save file physically on server.

Let me know if you have any questions.

Thanks
Keyur
 
Share this answer
 
Comments
SnvMohan 20-Sep-13 2:49am    
I can easily find upload control in panel...Problem arised when i try to get the extension of a file on upload control...
keyur satyadev 24-Sep-13 3:30am    
You need to use find control method (object.findcontrol("name of object")) to get the find upload control and then you can get the extension via its method. (i.e filename.ext)

hope this will clarify, still, if you have issue, revert me, will write syntax for you.

Thanks
Keyur
SnvMohan 25-Sep-13 8:13am    
k thank you sir...Still i dont try it out...when it success ill inform to u...

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