TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
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
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
271
35.8k
CRUD with Repeater in asp.net Entity Framework
Aug 10 2020 5:42 AM
hello...
i want to do CRUD operation with Repeater in asp.net Entity Framework.
<table
class
=
"style1"
>
<tr>
<td> CategoryName:</td>
<td>
<asp:TextBox ID=
"TxtCName"
runat=
"server"
></asp:TextBox>
</td>
<asp:RequiredFieldValidator ID=
"RequiredFieldValidator1"
runat=
"server"
Style=
"top:182px; left: 774px; position: absolute; height: 26px; width: 162px"
ControlToValidate=
"TxtCName"
ErrorMessage=
"required**"
font-size=
"Small"
ForeColor =
"Red"
></asp:RequiredFieldValidator>
</tr>
<tr>
<td>
<asp:Label ID=
"LblMesge"
runat=
"server"
></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td>
<asp:Button ID=
"Button1"
runat=
"server"
Text=
"Save"
class
=
"btn"
onclick=
"Button1_Click"
/>
</td>
</tr>
</table>
<asp:repeater id=
"repWalCat"
onitemcommand=
"repWalCat_ItemCommand"
runat=
"server"
>
<itemtemplate>
<table
class
=
"style1"
>
<tr>
<td> CategoryName:</td>
<td>
<asp:TextBox ID=
"TxtCName"
runat=
"server"
></asp:TextBox>
</td>
<asp:RequiredFieldValidator ID=
"RequiredFieldValidator1"
runat=
"server"
Style=
"top:182px; left: 774px; position: absolute; height: 26px; width: 162px"
ControlToValidate=
"TxtCName"
ErrorMessage=
"required**"
font-size=
"Small"
ForeColor =
"Red"
></asp:RequiredFieldValidator>
</tr>
</table>
</itemtemplate></asp:repeater>">
</div>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
bindCategoryToRepeater();
}
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
Model.WallpaperCategory newusermodel =
new
Model.WallpaperCategory();
newusermodel.CategoryName = TxtCName.Text;
newusermodel.CreatedDate = DateTime.Now;
newusermodel.UploadedDate = DateTime.Now;
using
(WallpaperEntities7 context =
new
WallpaperEntities7())
{
WallPaperCategry obj =
new
WallPaperCategry();
obj.CategoryName = newusermodel.CategoryName;
obj.CreatedDate = newusermodel.CreatedDate;
obj.UploadedDate = newusermodel.UploadedDate;
var cate = context.Set<WallPaperCategry>();
cate.Add(obj);
context.SaveChanges();
}
bindCategoryToRepeater();
}
void
bindCategoryToRepeater()
{
using
(WallpaperEntities7 context =
new
WallpaperEntities7())
{
repWalCat.DataSource = (from r
in
context.WallPaperCategries
select r).ToList();
repWalCat.DataBind();
}
}
protected
void
repWalCat_ItemCommand(
object
source, RepeaterCommandEventArgs e)
{
}
}
Reply
Answers (
4
)
How do we authorize static file in asp.net mvc?
Remove duplicate record in list