1). Hi AnandM, I have 2 questions more, the first is regarding to the code above, the panel is remain after I added "hfSelectedTab.Value = "6" "
like you told before. (This is successfully when I click to Edit link in gridview and the panel is remain) :
protected void GridViewCP_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string CpID = ((Label)e.Row.FindControl("lblcpID")).Text;
string StudentID = ((Label)e.Row.FindControl("lblStudentID")).Text;
e.Row.Cells[5].Visible = true;
e.Row.Cells[5].Text = "Edit";
HyperLink cp = new HyperLink();
cp.Text = e.Row.Cells[5].Text;
cp.NavigateUrl = "informationEdit.aspx?StudentID=" + StudentID + "&CpID="+ CpID;
e.Row.Cells[5].Controls.Add(cp);
}
}
But, since I want to refresh and added this code "Response.Redirect("informationEdit.aspx?StudentID=" + StudentID);",
the panel will go to the first panel. The reason I want to refresh is I want to get new record after saved and updated since I am using gridview
to display the record. If I not refresh the page, the new record will not appear.So, how to go the same panel or there has other way to display
the new and updated data?
This is the back code:
//////--Add Career Progress--//////////////////////////////////////////////////////////////////////
protected void btnSaveCP_Click(object sender, EventArgs e)
{
string StudentID = Request.QueryString["StudentID"];
con.Open();
string query = "InsertCareerProgress";
SqlCommand cmdCareerP = new SqlCommand(query, con);
cmdCareerP.CommandType = CommandType.StoredProcedure;
cmdCareerP.Parameters.Add("@StudentID", SqlDbType.Int).Value = Convert.ToInt32(StudentID);
cmdCareerP.Parameters.Add("@CpCompName", SqlDbType.NVarChar).Value = txtCPcompName.Text;
cmdCareerP.Parameters.Add("@CpCompAddress", SqlDbType.NVarChar).Value = txtCPcompAddr.Text;
cmdCareerP.Parameters.Add("@CpContractBond", SqlDbType.NVarChar).Value = ddlContractualBond.SelectedValue;
if (txtCpDateJoin.Text == "")
{
cmdCareerP.Parameters.AddWithValue("@CpDateJoined", System.DBNull.Value);
}
else
{
cmdCareerP.Parameters.Add("@CpDateJoined", SqlDbType.Date).Value = txtCpDateJoin.Text;
}
cmdCareerP.Parameters.Add("@CpPosition", SqlDbType.NVarChar).Value = txtCpPosition.Text;
cmdCareerP.Parameters.Add("@CpSBS", SqlDbType.NVarChar).Value = ddlCPsbs.SelectedValue;
if (txtcCpLWD.Text == "")
{
cmdCareerP.Parameters.AddWithValue("@CpLastDate", System.DBNull.Value);
}
else
{
cmdCareerP.Parameters.Add("@CpLastDate", SqlDbType.Date).Value = txtcCpLWD.Text;
}
if (txtLastDate.Text == "")
{
cmdCareerP.Parameters.AddWithValue("@CpSLastDate", System.DBNull.Value);
}
else
{
cmdCareerP.Parameters.Add("@CpSLastDate", SqlDbType.Date).Value = txtLastDate.Text;
}
cmdCareerP.Parameters.Add("@CpActPeriodServe", SqlDbType.NVarChar).Value = txtCpPeriodServe.Text;
cmdCareerP.Parameters.Add("@CpBalContractBond", SqlDbType.NVarChar).Value = txtBalContrBond.Text;
cmdCareerP.Parameters.Add("@CpTotal", SqlDbType.NVarChar).Value = txtSchoolAmount.Text;
cmdCareerP.Parameters.Add("@CpRemarks", SqlDbType.NVarChar).Value = txtCpRemarks.Text;
cmdCareerP.Parameters.Add("@CpDateCreated", SqlDbType.DateTime).Value = now;
cmdCareerP.ExecuteNonQuery();
con.Close();
Response.Redirect("informationEdit.aspx?StudentID=" + StudentID);
}
//////--Edit Career Progress--//////////////////////////////////////////////////////////////////////
protected void btnUpdateCP_Click(object sender, EventArgs e)
{
try
{
int dt1 = Convert.ToInt32(ddlCPsbs2.SelectedItem.Value);
string StudentID = Request.QueryString["StudentID"];
int Student_ID = Convert.ToInt32(StudentID);
string CpID = Request.QueryString["CpID"];
int Cp_ID = Convert.ToInt32(CpID);
con.Open();
string query = "UpdateCareerProgress";
SqlCommand cmdCareerP = new SqlCommand(query, con);
cmdCareerP.CommandType = CommandType.StoredProcedure;
cmdCareerP.Parameters.Add("@StudentID", SqlDbType.Int).Value = Convert.ToInt32(StudentID);
cmdCareerP.Parameters.Add("@CpID", SqlDbType.Int).Value = Convert.ToInt32(CpID);
cmdCareerP.Parameters.Add("@CpCompName", SqlDbType.NVarChar).Value = txtCPcompName2.Text;
cmdCareerP.Parameters.Add("@CpCompAddress", SqlDbType.NVarChar).Value = txtCPcompAddr2.Text;
cmdCareerP.Parameters.Add("@CpContractBond", SqlDbType.NVarChar).Value = ddlContractualBond2.SelectedValue;
cmdCareerP.Parameters.AddWithValue("@CpSBS", dt1);
if (txtCpDateJoin2.Text == "")
{
cmdCareerP.Parameters.AddWithValue("@CpDateJoined", System.DBNull.Value);
}
else
{
cmdCareerP.Parameters.Add("@CpDateJoined", SqlDbType.Date).Value = txtCpDateJoin2.Text;
}
cmdCareerP.Parameters.Add("@CpPosition", SqlDbType.NVarChar).Value = txtCpPosition2.Text;
if (txtcCpLWD2.Text == "")
{
cmdCareerP.Parameters.AddWithValue("@CpLastDate", System.DBNull.Value);
}
else
{
cmdCareerP.Parameters.Add("@CpLastDate", SqlDbType.Date).Value = txtcCpLWD2.Text;
}
if (txtLastDate2.Text == "")
{
cmdCareerP.Parameters.AddWithValue("@CpSLastDate", System.DBNull.Value);
}
else
{
cmdCareerP.Parameters.Add("@CpSLastDate", SqlDbType.Date).Value = txtLastDate2.Text;
}
cmdCareerP.Parameters.Add("@CpActPeriodServe", SqlDbType.NVarChar).Value = txtCpPeriodServe2.Text;
cmdCareerP.Parameters.Add("@CpBalContractBond", SqlDbType.NVarChar).Value = txtBalContrBond2.Text;
cmdCareerP.Parameters.Add("@CpTotal", SqlDbType.NVarChar).Value = txtSchoolAmount2.Text;
cmdCareerP.Parameters.Add("@CpRemarks", SqlDbType.NVarChar).Value = txtCpRemarks2.Text;
cmdCareerP.Parameters.Add("@CpDateModified", SqlDbType.DateTime).Value = now;
cmdCareerP.ExecuteNonQuery();
Response.Redirect("informationEdit.aspx?StudentID=" + StudentID);
con.Close();
}
catch (Exception ex)
{
lblmsgCareerPro.Text = ex.Message;
}
}
--------------------------------------------------------------------------------------------------------------------------
2). Second question is how to remove extra empty space in the STUDENT INFORMATION - FAMILY PARTICULARS body since STUDENT INFORMATION - STUDENT DETAILS panel has many form
than STUDENT INFORMATION - FAMILY PARTICULARS. Since this is the default body height, do I need to add one more <div class> for content or just set the height for
the content?
<div id="dvAccordian">
<div class="HeaderContent"> STUDENT INFORMATION - STUDENT DETAILS</div>
<div>
<asp:Panel width="100%" ID="PanelStudentDetailsAdd" runat="server" >
<table width="95%" align="center" border="0" cellspacing="3" cellpadding="3">
<tr>
<td >
<tr>
<td class="bar" align="center">
<b>PERSONAL DETAILS</b>
</td>
</tr>
<tr><td align="center"><asp:Label id="lblmsg" runat="server" ForeColor="Red" Display="Dynamic"/>
<asp:CustomValidator ID="cvAddStudent" ErrorMessage="" SetFocusOnError="true" runat="server" Display="Dynamic" OnServerValidate="cvAddStudent_ServerValidate" ValidationGroup="ValidateClick" Font-Italic="True" ForeColor="Red"></asp:CustomValidator>
<br />
</td></tr>
<tr>
<td align="center">
<br />
<table width="95%" border="0" cellpadding="2" cellspacing="2">
<tr valign="top" >
<td width="16%">Full Name</td>
<td width="28%"><asp:TextBox ID="txtstdName" runat="server" Width="220px" />
<asp:Label ID="Label14" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label></td>
<td width="16%">Gender </td>
<td width="27%"><asp:DropDownList ID="ddlstdGender" runat="server" Width="220px" Height="23" DataTextField="Gender">
<asp:ListItem Value="0">SELECT</asp:ListItem>
<asp:ListItem Value="Male"></asp:ListItem>
<asp:ListItem Value="Female"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr valign="top">
<td>IC No</td>
<td><asp:TextBox ID="txtstdIcNo" runat="server" MaxLength="14" Width="220px"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
<br /><asp:RegularExpressionValidator ID="empic" runat="server" ControlToValidate="txtstdIcNo" ErrorMessage="Enter valid IC No with Dash(-)" ValidationExpression="^\d{6}-\d{2}-\d{4}$" ForeColor="Red" Display="Dynamic" ValidationGroup="ValidateClick" />
</td>
<td>Ethnicity </td>
<td><asp:DropDownList ID="ddlstdEthnic" DataSourceID="sqlDataSourceEthnicity" DataTextField="Ethnicity" DataValueField="EthnicityID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr valign="top">
<td>D.O.B</td>
<td><asp:TextBox ID="txtstdDOB" runat="server" MaxLength="14" Width="220px"/>
</td>
<td>Age</td>
<td><asp:TextBox ID="txtstdAgee" runat="server" Width="220px"/>
<br /><asp:RegularExpressionValidator ID="evPAgee" runat="server" ControlToValidate="txtstdAgee" ErrorMessage="Invalid age" ValidationExpression="[0-9]{1,}" ForeColor="Red" Display="Dynamic" ValidationGroup="ValidateClick" />
</td>
</tr>
<tr valign="top">
<td>Parent marital Status </td>
<td><asp:DropDownList ID="ddlstdMaritalStatus" DataSourceID="sqlDataSourceMaritalStatus" DataTextField="MaritalStatus" DataValueField="MaritalStatusID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="0">SELECT</asp:ListItem>
</asp:DropDownList>
</td>
<td>Number of Sibling</td>
<td><asp:TextBox ID="txtstdNoSib" runat="server" Width="220px"/>
<br /><asp:RegularExpressionValidator ID="evnosibling" runat="server" ControlToValidate="txtstdNoSib" ErrorMessage="Invalid number of sibling" ValidationExpression="[0-9]{1,}" ForeColor="Red" Display="Dynamic" ValidationGroup="ValidateClick" />
</td>
</tr>
<tr valign="top">
<td>Religion</td>
<td colspan ="3"><asp:DropDownList ID="ddlstdReligion" DataSourceID="sqlDataSourceReligion" DataTextField="Religion" DataValueField="ReligionID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
<br />
</td>
</tr>
<tr>
<td class="bar" align="center">
<b>CONTACT INFORMATION</b>
</td>
</tr>
<tr>
<td align="center">
<br />
<table width="95%" border="0" cellpadding="2" cellspacing="2">
<tr valign="top">
<td width="16%">Current Address </td>
<td colspan="3"><asp:TextBox ID="txtstdCurAdd" runat="server" Width="96%" TextMode="MultiLine"/></td>
</tr>
<tr valign="top">
<td>Correspondence Address </td>
<td colspan="3"><asp:TextBox ID="txtstdCorAdd" runat="server" Width="96%" TextMode="MultiLine" /></td>
</tr>
<tr valign="top">
<td width="16%">Mobile No </td>
<td width="28%"><asp:TextBox ID="txtstdMobile" runat="server" Width="220px" /></td>
<td width="16%">Residence No</td>
<td width="27%"><asp:TextBox ID="txtstdResidence" runat="server" Width="220px" /></td>
</tr>
<tr valign="top">
<td width="16%">Email </td>
<td colspan="3"><asp:TextBox ID="txtstdEmail" runat="server" Width="220px"/>
<br /><asp:RegularExpressionValidator ID="apemailExp" runat="server" controltovalidate="txtstdEmail" errormessage="Invalid email address" ForeColor="Red" Display="Dynamic" validationexpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ValidationGroup="ValidateClick"></asp:RegularExpressionValidator>
</td>
</tr>
</table>
<br />
</td>
</tr>
<tr>
<td class="bar" align="center">
<b>STUDENT DETAILS</b>
</td>
</tr>
<tr>
<td align="center">
<br />
<table width="95%" border="0" cellpadding="2" cellspacing="2">
<tr valign="top">
<td width="16%">Scholarship</td>
<td width="28%"><asp:DropDownList ID="ddlstdScholarship" DataSourceID="sqlDataSourcestdScholarship" DataTextField="Scholarship" DataValueField="ScholarshipID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblscholar" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
</td>
<td width="16%">Batch</td>
<td width="27%"><asp:DropDownList ID="ddlstdBatch" runat="server" DataSourceID="SqlDataSourceBatch" DataTextField="Batch" DataValueField="BatchID" AppendDataBoundItems="true" AutoPostBack="true" OnSelectedIndexChanged="Batch_SelectedIndexChanged" Height="23px" Width="220px">
<asp:ListItem Text="SELECT" value=""></asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label10" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
</td>
</tr>
<tr valign="top">
<td>Institution</td>
<td><asp:DropDownList ID="ddlstdInstitution" DataSourceID="sqlDataSourcestdInstitution" DataTextField="Institution" DataValueField="InstitutionID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label4" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
</td>
<td>Intake</td>
<td><asp:DropDownList ID="ddlstdIntake" runat="server" DataSourceID="SqlDataSourceIntake" DataTextField="Intake" DataValueField="IntakeID" AppendDataBoundItems="true" Height="23" Width="220px">
<asp:ListItem Text="SELECT" value=""></asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label37" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
</td>
</tr>
<tr valign="top">
<td>Field of Study</td>
<td><asp:DropDownList ID="ddlstdStudyField" DataSourceID="sqlDataSourceStdStudyField" DataTextField="StudyField" DataValueField="StudyFieldID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label5" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
</td>
<td>Fly Date </td>
<td><asp:TextBox ID="txtstdFly" runat="server" Width="220px" Height="23" />
</td>
</tr>
<tr valign="top">
<td>Course</td>
<td><asp:DropDownList ID="ddlstdCourse" DataSourceID="sqlDataSourcestdCourse" DataTextField="CourseDescription" DataValueField="CourseID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label6" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
</td>
<td>Graduate Year</td>
<td><asp:DropDownList ID="ddlstdYear" DataSourceID="sqlDataSourcestdYear" DataTextField="Year" DataValueField="YearID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label2" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
</td>
</tr>
<tr>
<td>Country</td>
<td><asp:DropDownList ID="ddlstdCountry" DataSourceID="sqlDataSourcestdCountry" DataTextField="Country" DataValueField="CountryID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
</td>
<td>Status</td>
<td><asp:DropDownList ID="ddlstdUserStatus" DataSourceID="sqlDataSourcestdUserStatus" DataTextField="UserStatus" DataValueField="UserStatusID" AppendDataBoundItems="true" runat="server" Font-Strikeout="False" Height="23" Width="220px">
<asp:ListItem Value="">SELECT</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label8" runat="server" Font-Strikeout="False" ForeColor="Red" Text=" * "></asp:Label>
</td>
</tr>
</table>
<br />
</td>
</tr>
<tr>
<td class="bar" align="center">
<b>OTHERS</b>
</td>
</tr>
<tr>
<td align="center">
<br />
<table width="95%" border="0" cellpadding="2" cellspacing="2">
<tr valign="Top">
<td width="18%">Photo</td>
<td colspan="3"><asp:FileUpload ID="imgUpload" runat="server" Width="410px" /></td>
</tr>
<tr valign="Top">
<td width="18%">Remarks</td>
<td colspan="3"><asp:TextBox ID="txtstdRemarks" runat="server" Height="60px" Width="410px" TextMode="MultiLine" /></td>
</tr>
<tr><td> </td>
<td><span><em>(Scholarship Agreement, Health Report)</span></em></td>
</tr>
<tr valign="top">
<td>File 1</td>
<td><asp:FileUpload ID="upAttachment1" runat="server" Width="410px" /></td>
</tr>
<tr valign="top">
<td>File 2</td>
<td><asp:FileUpload ID="upAttachment2" runat="server" Width="410px" /><br /></td>
</tr>
<tr valign="top">
<td>File 3</td>
<td><asp:FileUpload ID="upAttachment3" runat="server" Width="410px" /></td>
</tr>
<tr valign="top">
<td>File 4</td>
<td><asp:FileUpload ID="upAttachment4" runat="server" Width="410px" /><br /></td>
</tr>
<tr>
<td colspan="2" align="center">
<br />
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSaveStudent_Click" ValidationGroup="ValidateClick" OnClientClick="return Validate()" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
<br /><br />
</td>
</tr>
</table>
<br />
</td>
</tr>
</table>
</asp:Panel>
</div>
<!--/////////////////////////////////////////////////////////////////////////--FAMILY PARTICULARS--/////////////////////////////////////////////////////////////////////-->
<div class="HeaderContent"> STUDENT INFORMATION - FAMILY PARTICULARS</div>
<div>
<table width="95%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td align="center">
<br />
<table width="95%" border="0" cellpadding="2" cellspacing="2">
<tr valign="top">
<td width="16%">Current Address </td>
<td colspan="3"><asp:TextBox ID="TextBox1" runat="server" Width="96%" TextMode="MultiLine"/></td>
</tr>
<tr valign="top">
<td>Correspondence Address </td>
<td colspan="3"><asp:TextBox ID="TextBox2" runat="server" Width="96%" TextMode="MultiLine" /></td>
</tr>
<tr valign="top">
<td width="16%">Mobile No </td>
<td width="28%"><asp:TextBox ID="TextBox3" runat="server" Width="220px" /></td>
<td width="16%">Residence No</td>
<td width="27%"><asp:TextBox ID="TextBox4" runat="server" Width="220px" /></td>
</tr>
<tr valign="top">
<td width="16%">Email </td>
<td colspan="3"><asp:TextBox ID="TextBox5" runat="server" Width="220px"/>
<br /><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" controltovalidate="txtstdEmail" errormessage="Invalid email address" ForeColor="Red" Display="Dynamic" validationexpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ValidationGroup="ValidateClick"></asp:RegularExpressionValidator>
</td>
</tr>
</table>
<br />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<br />
<asp:Button ID="Button1" runat="server" Text="Save" OnClick="btnSaveStudent_Click" ValidationGroup="ValidateClick" OnClientClick="return Validate()" />
<asp:Button ID="Button2" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
<br /><br />
</td>
</tr>
</table>
</div>
<!--/////////////////////////////////////////////////////////////////////////--SURETIES--/////////////////////////////////////////////////////////////////////-->
<div class="HeaderContent"> STUDENT INFORMATION - SURETIES</div>
<div>
</div>
<!--/////////////////////////////////////////////////////////////////////////--ACADEMIC--/////////////////////////////////////////////////////////////////////-->
<div class="HeaderContent"> STUDENT INFORMATION - ACADEMIC</div>
<div>
</div>
<!--/////////////////////////////////////////////////////////////////////////--PROFESSIONAL BODY--/////////////////////////////////////////////////////////////////////-->
<div class="HeaderContent"> STUDENT INFORMATION - PROFESSIONAL BODY</div>
<div>
</div>
<!--/////////////////////////////////////////////////////////////////////////--ACTIVITIES--/////////////////////////////////////////////////////////////////////-->
<div class="HeaderContent"> STUDENT INFORMATION - ACTIVITIES</div>
<div>
</div>
<!--/////////////////////////////////////////////////////////////////////////--CAREER PROGRESS--/////////////////////////////////////////////////////////////////////-->
<div class="HeaderContent"> STUDENT INFORMATION - CAREER PROGRESS</div>
<div>
</div>
</div>
Kindly help me...