D
Dhananjay
hi all
i have a problem on populating a message on asp:label server control.I
am able to insert records into the table.but it is not populating any
message like "Records entered successfully". i wanted to implement
this .how to proceed can anybody tell me about this . i am using
asp.net/vb.net 2.0
here i am providing the code also:-
vb code:-
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As
EventArgs)
If Page.IsPostBack = True Then
Dim dbcon As SqlConnection
dbcon = New SqlConnection("Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HRISDB.mdf;Integrated
Security=True;User Instance=True")
Dim dbcom As New SqlCommand()
dbcom.Connection = dbcon
dbcom.CommandType = CommandType.Text
dbcom.CommandText = "Insert into
TalentTeam(TalentTeamName) values(@TalentTeamName)"
dbcom.Parameters.Add("@TalentTeamName", SqlDbType.VarChar)
dbcom.Parameters("@TalentTeamName").Value =
txtRecruiterName.Text.ToString()
If txtRecruiterName.Text.Length = 0 Then
dbcom.Parameters("@TalentTeamName").Value =
System.DBNull.Value
Else
dbcom.Parameters("@TalentTeamName").Value =
txtRecruiterName.Text
End If
Try
dbcon.Open()
dbcom.ExecuteNonQuery()
lblMessage.Visible = "True"
txtRecruiterName.Text = ""
Dim result As Integer
result = dbcom.ExecuteNonQuery()
If result = 0 Then
lblMessage.Text = "Record not entered
successfully"
Else
lblMessage.Text = "Record entered successfully"
End If
Catch ex As Exception
Response.Write(ex.Message)
Response.End()
Finally
If dbcon.State = ConnectionState.Open Then
dbcon.Close()
End If
End Try
Response.Redirect("~/AddForms/addRecruiter.aspx")
Else
lblMessage.Text = "Please enter Recruiter Name"
End If
End Sub
..aspx code :-
<table>
<tr>
<td>
<aspanel ID="PanelEffectiveDate"
runat="server" >
<table>
<tr>
<td
align="center">
<asp:Label
ID="lblAddRecruiter" runat="server" Text="Recruiter Name" ></
asp:Label>
</td>
<td align="right">
<asp:TextBox
ID="txtRecruiterName" runat="server" Text="" ></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEnterRecruiterName" runat="server"
ControlToValidate="txtRecruiterName" ErrorMessage="Plase Enter
Recruiter Name"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="3" align="right">
<asp:Button ID="btnAdd"
runat="server" Text="ADD" OnClick="btnAdd_Click" />
</td>
</tr>
<tr>
<td colspan="2"
align="center">
<asp:Label ID="lblMessage"
runat="server" Font-Bold="true" ForeColor="blue" ></asp:Label>
</td>
</tr>
</table>
</aspanel>
</td>
</tr>
</table>
please help me know to solve this issue.
Thanks in advance
Dhananjay
i have a problem on populating a message on asp:label server control.I
am able to insert records into the table.but it is not populating any
message like "Records entered successfully". i wanted to implement
this .how to proceed can anybody tell me about this . i am using
asp.net/vb.net 2.0
here i am providing the code also:-
vb code:-
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As
EventArgs)
If Page.IsPostBack = True Then
Dim dbcon As SqlConnection
dbcon = New SqlConnection("Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HRISDB.mdf;Integrated
Security=True;User Instance=True")
Dim dbcom As New SqlCommand()
dbcom.Connection = dbcon
dbcom.CommandType = CommandType.Text
dbcom.CommandText = "Insert into
TalentTeam(TalentTeamName) values(@TalentTeamName)"
dbcom.Parameters.Add("@TalentTeamName", SqlDbType.VarChar)
dbcom.Parameters("@TalentTeamName").Value =
txtRecruiterName.Text.ToString()
If txtRecruiterName.Text.Length = 0 Then
dbcom.Parameters("@TalentTeamName").Value =
System.DBNull.Value
Else
dbcom.Parameters("@TalentTeamName").Value =
txtRecruiterName.Text
End If
Try
dbcon.Open()
dbcom.ExecuteNonQuery()
lblMessage.Visible = "True"
txtRecruiterName.Text = ""
Dim result As Integer
result = dbcom.ExecuteNonQuery()
If result = 0 Then
lblMessage.Text = "Record not entered
successfully"
Else
lblMessage.Text = "Record entered successfully"
End If
Catch ex As Exception
Response.Write(ex.Message)
Response.End()
Finally
If dbcon.State = ConnectionState.Open Then
dbcon.Close()
End If
End Try
Response.Redirect("~/AddForms/addRecruiter.aspx")
Else
lblMessage.Text = "Please enter Recruiter Name"
End If
End Sub
..aspx code :-
<table>
<tr>
<td>
<aspanel ID="PanelEffectiveDate"
runat="server" >
<table>
<tr>
<td
align="center">
<asp:Label
ID="lblAddRecruiter" runat="server" Text="Recruiter Name" ></
asp:Label>
</td>
<td align="right">
<asp:TextBox
ID="txtRecruiterName" runat="server" Text="" ></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEnterRecruiterName" runat="server"
ControlToValidate="txtRecruiterName" ErrorMessage="Plase Enter
Recruiter Name"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="3" align="right">
<asp:Button ID="btnAdd"
runat="server" Text="ADD" OnClick="btnAdd_Click" />
</td>
</tr>
<tr>
<td colspan="2"
align="center">
<asp:Label ID="lblMessage"
runat="server" Font-Bold="true" ForeColor="blue" ></asp:Label>
</td>
</tr>
</table>
</aspanel>
</td>
</tr>
</table>
please help me know to solve this issue.
Thanks in advance
Dhananjay