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
sangeetha k
NA
207
51.3k
Y am i coulnt redirect to the actionresult in mvc
Apr 19 2018 4:07 AM
i wish to search records in the gridview but it is not redirecting to the method which iam pointing to what would be the problem can any one help me out with this?
#Dal
public
void
SearchRecord(
string
searchBy,
string
txtSearch)
{
try
{
EmployeeEntity emp =
new
EmployeeEntity();
using
(AdventureWorksEntities empDbentity =
new
AdventureWorksEntities())
{
if
( searchBy==
"Name"
)
{
var result=empDbentity.tblEmployees.Where(x=>x.Empname.StartsWith(txtSearch) || txtSearch==
null
).ToList();
}
else
{
var result=empDbentity.tblEmployees.Where(x=>x.Empid==Convert.ToInt32(txtSearch)||txtSearch==
null
).ToList();
}
}
}
catch
(Exception ex)
{
Log.WriteError(
"BorrowerImageGridView.EmployeeDataAcess.searchRecord()"
, ex);
throw
new
Exception(TUtil.GetMethodExceptionContext(searchBy, txtSearch), ex);
}
#bll
public
void
SearchRecord(
string
searchBy,
string
txtSearch)
{
try
{
empdata.SearchRecord(searchBy, txtSearch);
}
catch
(Exception ex)
{
throw
new
Exception(TUtil.GetMethodExceptionContext(searchBy, txtSearch), ex);
}
}
#contoller
[HttpGet]
public
ActionResult SearchRecord(
string
searchBy,
string
txtSearch)
{
empservice.SearchRecord(searchBy,txtSearch);
return
RedirectToAction(
"EmployeeDetails"
);
}
#view
@using (Html.BeginForm(
"SearchRecord"
,
" Employee"
, FormMethod.Get))
{
<div>
<div
class
=
"input-group"
>
<b>Search By:</b>
@Html.RadioButton(
"searchBy"
,
"Empname"
,
true
)Name
@Html.RadioButton(
"searchBy"
,
"Empid"
)EmployeeId
@Html.TextBox(
"txtSearch"
,
""
,
new
{ @id =
"txtSearch"
, @
class
=
"form-control"
, style =
" margin-bottom: 25px ;align-content:center; font-family:Arial, FontAwesome"
, placeholder =
"Search"
})
@*<input type=
"text"
class
=
"form-control"
id=
"txtSearch"
placeholder=
"Search for..."
>*@
<span
class
=
"input-group-btn"
>
<button id=
"btnSearch"
class
=
"btn btn-secondary"
style=
"margin-bottom:4px;"
type=
"submit"
><i
class
=
"glyphicon glyphicon-search"
></i></button>
</span>
</div>
@*<input id=
"txtSearch"
style=
" margin-bottom: 25px ;font-family:Arial, FontAwesome"
type=
"text"
placeholder=
" ? Search "
name=
" search"
>
<button type=
"button"
class
=
"btn btn-info"
style=
" margin-bottom: 25px"
>
<span
class
=
" glyphicon glyphicon-search"
>
</span> Search
</button>*@
</div>
}
Reply
Answers (
3
)
Change the cell position of the Panel dynamically
How to set connectionstring value from .xml file in asp.net