10 TIPs - To Become a Good Developer/Programmer
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Hold On
1.2k
1k
182.8k
Three Tier Structure (from code behind to data access)
Mar 5 2018 1:18 AM
Hello everyone, I created an xml file from a gridview (thanks to Rakesh article). My application is done using a 3 tier structure. How will I transfer my code behind to data access and call only the xml from my code behind? Please see code below.
StringBuilder sbSubjects =
new
StringBuilder();
sbSubjects.AppendLine(
"<?xml version=\"1.0\" ?>"
);
foreach
(GridViewRow row
in
GridView1.Rows)
{
Label SubjectID = (Label)row.FindControl(
"lblSubjectId"
);
string
lblEnrollmentId = lblEnrollmentID.Text.Trim();
if
(SubjectID ==
null
|| lblEnrollmentId ==
null
)
{
return
;
}
if
(
string
.IsNullOrEmpty(SubjectID.Text.Trim()) ||
string
.IsNullOrEmpty(lblEnrollmentId))
{
return
;
}
else
{
sbSubjects.AppendLine(
"<tblEnrolledSubjects>"
);
sbSubjects.AppendLine(
" <subjects>"
);
sbSubjects.AppendLine(
" <SubjectId>"
+ SubjectID.Text.Trim() +
"</SubjectId>"
);
sbSubjects.AppendLine(
" <EnrollmentID>"
+ lblEnrollmentId +
"</EnrollmentID>"
);
sbSubjects.AppendLine(
" </subjects>"
);
sbSubjects.AppendLine(
"</tblEnrolledSubjects>"
);
}
}
SqlCommand cmdSubjects =
new
SqlCommand(
"[dbo].[spInsert_XML_BulkEnrollmentSubjects]"
, con, transaction);
cmdSubjects.CommandType = CommandType.StoredProcedure;
cmdSubjects.Parameters.AddWithValue(
"@SubjectsData"
, sbSubjects.ToString());
Reply
Answers (
4
)
url writing in global.asax
onchange event for dropdown list