when user register the data,The data has been inserted into the database but a single user is going to login in the form while login the enter data in the database has been viewed in the user details page.but i need only a particular data of the user. and check my code in case of error so please mention me.
Below Attached database screenshot
in this screen shot two user saved information from the database (ID 1
And ID 10003
). if ID=1
user login the details of the particular user need to be viewed but in this case if any one of the user login the whole database users details has been displayed. how to rectify the problem.
<div class="tg-bordertop tg-haslayout">
<div class="tg-formsection tg-experience">
<div class="tg-heading-border tg-small">
<h3>Doctor Social Network</h3>
</div>
<asp:HiddenField ID="hdnsocial" runat="server" />
<div class="tg-education-detail tg-haslayout">
<asp:Repeater ID="rptsocial" runat="server">
<HeaderTemplate>
<div class="table-responsive">
<table class="table-striped educations_wrap table" id="table-striped">
<thead class="cf">
<tr>
<th>Facebook</th>
<th>Twitter</th>
<th>linkedin</th>
<th>Pinterest</th>
<th>GooglePlusID</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody class="educations_item">
<tr>
<td data-title="FaceBook"><asp:Label ID="lblFaceBookID" runat="server" Text='<%# Eval("FaceBookID") %>' />
<div class="tg-table-hover education-action">
<a id='<%#Eval("DoctorSocialID")%>' href="javascript:;" class="delete-me" data-toggle="modal" data-target="#Socialdelete<%#Eval("DoctorSocialID")%>"><i class="tg-delete fa fa-close"></i></a>
<a id='<%#Eval("DoctorSocialID")%>' data-toggle="modal" data-target="#Socialedit<%#Eval("DoctorSocialID")%>" href="javascript:;" class="edit-me EditSocial"><i class="tg-edit fa fa-pencil"></i></a>
</div>
<td data-title="Twitter"><asp:Label ID="lbiTwitterID" runat="server" Text='<%# Eval("TwitterID") %>' /></td>
<td data-title="linkedin"><asp:Label ID="lbllinkedinID" runat="server" Text='<%# Eval("linkedinID") %>' /></td>
<td data-title="Pinterest"><asp:Label ID="lblPinterestID" runat="server" Text='<%# Eval("PinterestID") %>' /></td>
<td data-title="GooglePlus"><asp:Label ID="lblGooglePlusID" runat="server" Text='<%# Eval("GooglePlusID") %>' /></td>
</td>
</tr>
<tr>
<td>
<div class="modal fade bs-example-modal-lg" id='Socialedit<%#Eval("DoctorSocialID")%>' tabindex="-1"
role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="background-color:black;">
<div class="modal-header" style="background-color:white;">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×</button>
<h4 id="myModalLabel">
Edit Social Network</h4>
</div>
<div class="modal-body" style="background-color:white;">
<div class="errorEditTitle">
</div>
<table class="index-table">
<tr>
<td>
<label>
FaceBook<sub>*</sub></label>
</td>
<td>
<asp:TextBox ID="txtFaceBookID" runat="server" onchange="javascript:EditSocialvalue(this);" Text='<%#Eval("FaceBookID")%>' required class="form-control"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<label>
Twitter<sub>*</sub></label>
</td>
<td>
<asp:TextBox ID="txtTwitterID" runat="server" Class="form-control" onchange="javascript:EditSocialvalue1(this);" required Text='<%#Eval("TwitterID")%>' ></asp:TextBox>
</td>
</tr>
<tr>
<td>
<label>
linkedin<sub>*</sub></label>
</td>
<td>
<asp:TextBox ID="txtlinkedinID" runat="server" Class="form-control" Text='<%#Eval("linkedinID")%>' onchange="javascript:EditSocialvalue2(this);" ></asp:TextBox>
</td>
</tr>
<tr>
<td>
<label>
Pinterest<sub>*</sub></label>
</td>
<td>
<asp:TextBox ID="txtPinterestID" runat="server" Class="form-control" Text='<%#Eval("PinterestID")%>' onchange="javascript:EditSocialvalue3(this);"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<label>
GooglePlus<sub>*</sub></label>
</td>
<td>
<asp:TextBox ID="txtGooglePlusID" runat="server" Class="form-control" Text='<%#Eval("GooglePlusID")%>' onchange="javascript:EditSocialvalue4(this);"></asp:TextBox>
</td>
</tr>
</table>
</div>
<div class="modal-footer" style="background-color:white;">
<input type="button" class="btn btn-success" id="btnEditSocial"
value="Update" name="<%#Eval("DoctorSocialID")%>" />
<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">
Cancel</button>
</div>
</div>
<!----------------------------------------------------
* Delete HTML Tempaltes
------------------------------------------------- -->
<!-- Modal -->
<div class="modal fade bs-example-modal-lg" id='Socialdelete<%#Eval("DoctorSocialID")%>' role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content" style="width:350px">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Delete Confirmation</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this record?<br /></p>
</div><br />
<div class="modal-footer">
<button class="btn button" data-dismiss="modal" aria-hidden="true">
Cancel</button>
<input type="button" class="btn btn-danger" id="btnDeleteSocial"
value="Delete" name="<%#Eval("DoctorSocialID")%>" />
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</ItemTemplate>
<FooterTemplate>
</table>
</div>
</FooterTemplate>
</asp:Repeater>
</div>
<div class="col-sm-12">
<div class="tg-addfield add-new-experiences">
<button type="button" id="AddSocialNetwork">
<i class="fa fa-plus"></i>
<span>Add Social Network</span>
</button>
</div>
</div>
</div>
</div>
<!--Start Social -->
<div class="tg-bordertop tg-haslayout" id="ShowSocialNetwork" style="display:none;">
<div class="tg-formsection tg-education">
<div class="tg-heading-border tg-small">
<h3>Add Social Network</h3>
</div>
<div class="tg-education-detail tg-haslayout">
<table class="table-striped educations_wrap" id="table1">
<thead class="cf">
<tr>
<th>Facebook</th>
<th>Twitter</th>
<th>linkedin</th>
<th>Pinterest</th>
<th>GooglePlusID</th>
</tr>
</thead>
<tbody class="educations_item">
<tr>
<td class="education-data edit-me-row" colspan="5">
<div class="education-data-wrap">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="form-group">
<asp:TextBox ID="txtFaceBookID" runat="server" Class="form-control" placeholder="FaceBook ID"></asp:TextBox>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="form-group">
<asp:TextBox ID="txtTwitterID" runat="server" Class="form-control" placeholder="Twitter ID"></asp:TextBox>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="form-group">
<asp:TextBox ID="txtlinkedinID" runat="server" Class="form-control" placeholder="linkedinID"></asp:TextBox>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="form-group">
<asp:TextBox ID="txtPinterestID" runat="server" Class="form-control" placeholder="Pinterest"></asp:TextBox>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="form-group">
<asp:TextBox ID="txtGooglePlusID" runat="server" Class="form-control" placeholder="GooglePlus"></asp:TextBox>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="form-group">
<input type="button" id="btnSocial" class="btn btn-success" value="Save Social" />
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!--End Socail -->
Save database function code:
function SaveDocSocial(response) {
if (response == null) {
callAjax({
url: pageUrl + '/SaveDocSocial',
data: '{"Doctorid": "' + $("#<%=hdnDoctorId.ClientID %>").val() + '","DoctorSocialID" : "' + $("#<%=hdnsocial.ClientID %>").val() + '","FaceBookID" : "' + $("#<%=txtFaceBookID.ClientID %>").val() + '","TwitterID" : "' + $("#<%=txtTwitterID.ClientID %>").val() + '","linkedinID" : "' + $("#<%=txtlinkedinID.ClientID %>").val() + '","PinterestID" : "' + $("#<%=txtPinterestID.ClientID %>").val() + '","GooglePlusID" : "' + $("#<%=txtGooglePlusID.ClientID %>").val() + '"}',
action: "SaveDocSocial"
});
window.location.reload();
}
else {
loading(false);
if (response.AjxContactId != null) {
$('#<%=hdnsocial.ClientID%>').val(response.AjxContactId);
}
msg(true, response.Message);
}
}
And Page load
this.BindSocial();
if (iDoctorID > 0)
{hdnsocial.Value = iDoctorID.ToString();
}
Save Code
[WebMethod]
public static UserAjax SaveDocSocial(string Doctorid, string DoctorSocialID, string FaceBookID, string TwitterID, string linkedinID, string PinterestID, string GooglePlusID)
{
UserAjax oUserAjax = new UserAjax();
string CDoctorID = string.Empty;
string DSocialID = string.Empty;
int iDoctorID = 0;
int iDoctorSocialID = 0;
CDoctorID = Doctorid == null ? "" : Doctorid;
if (Validation.IsShort(CDoctorID))
iDoctorID = Convert.ToInt32(CDoctorID);
DSocialID = DoctorSocialID == null ? "" : DoctorSocialID;
if (Validation.IsShort(DSocialID))
iDoctorSocialID = Convert.ToInt32(DSocialID);
string sMessage = string.Empty;
string sBuild = string.Empty;
if (sMessage != "")
{
oUserAjax.Message = sMessage;
}
else
{
BD_Doctor iDoctor = new BD_Doctor();
iDoctor.DoctorID = iDoctorID;
iDoctor.DoctorSocialID = iDoctorSocialID;
iDoctor.FaceBookID = FaceBookID;
iDoctor.TwitterID = TwitterID;
iDoctor.linkedinID = linkedinID;
iDoctor.PinterestID = PinterestID;
iDoctor.GooglePlusID = GooglePlusID;
iDoctor.SaveSocial();
//iDoctor.IsDefault = true;
if (iDoctorID > 0)
{
sMessage = "Clinic Information successfully saved!";
oUserAjax.AjxContactId = iDoctorID.ToString();
oUserAjax.Message = sMessage;
}
else
{
sMessage = "Your submission failed!";
oUserAjax.Message = sMessage;
}
}
return oUserAjax;
}
View Repeater Code :
private void BindSocial()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Doctorsocialnetwork", con))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
rptsocial.DataSource = dt;
rptsocial.DataBind();
}
}
}
}