Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
3
Answers
Y am i coulnt redirect to the actionresult in mvc
sangeetha k
6y
502
1
Reply
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>
}
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Change the cell position of the Panel dynamically
How to set connectionstring value from .xml file in asp.net