Fetch data from database & display using entity framework asp.net c#GUGuest User6yAsked Jul 15, 2020, 10:59 AM EDTSolvedShareLinkedInXCopy linkSaveFetch or retrive data and display in textbox using entity framework in asp.net C#
Fetch data from database & display using entity framework asp.net c#GUGuest User6yAsked Jul 15, 2020, 10:59 AM EDTSolvedShareLinkedInXCopy linkSaveFetch or retrive data and display in textbox using entity framework in asp.net C#
Sachin SinghRank #66 · 26.2K reputation6y agoPosted Jul 16, 2020, 10:16 PM EDT✓ Accepted answer+3@Nivi yes how linq to Entites will recognize it, its wrong sorry for that first convert the session to string before using it in linq query like below string UName=Convert.ToString(Session["UserName"]);then use it in query var query = (from c in context.Users where c.userName==UName select new {}+3
Sachin SinghRank #66 · 26.2K reputation6y agoPosted Jul 16, 2020, 9:13 PM EDT+2So you are allowing users to edit their profile. There is no need to create two forms follow below steps:-1.Ask user to log in by his username and psd.2.Save the username in session (if you are not using identity)3.On Edit profile click WallpaperEntities3 context = new WallpaperEntities3(); var query = (from c in context.Users where c.userName==Convert.ToString(session[userName]); select new { c.Name, c.UserName, c.EmailID, c.Password, c.Confirm_Password }).FirstOrDefault(); if (query != null) { TxtName.Text = query.Name; TxtUserName.Text = query.UserName; TxtEmailID.Text = query.EmailID; TxtPassword.Text = query.Password; TxtConfirmPassword.Text = query.Confirm_Password; } } } +2
Santhakumar MunuswamyRank #128 · 17.3K reputation6y agoPosted Jul 15, 2020, 5:49 PM EDT+1Hi Nivi Sharma, you can check out the below link and I think, this reference will give you some idea to find a way to your question https://www.c-sharpcorner.com/article/entity-framework-basic-guide-to-perform-fetch-filter-insert-update-and-dele/ https://www.aspsnippets.com/Articles/Retrieve-Display-data-from-Database-in-TextBoxes-in-ASPNet-MVC.aspx Let me know if you have the opportunity to get some ideas. +1
GUGuest UserRank #3,979 · 374 reputation6y agoPosted Jul 16, 2020, 9:05 AM EDT+1Hi Santhakumar Munuswamy,Its nt working.+1
GUGuest UserRank #3,979 · 374 reputation6y agoPosted Jul 16, 2020, 9:06 AM EDT+1hi Atul Warade,,not working ' +1
Santhakumar MunuswamyRank #128 · 17.3K reputation6y agoPosted Jul 16, 2020, 9:06 AM EDT+1Hi Nivi, you can share your code what you have tried so far. i will check and let you know +1
Atul WaradeRank #1,357 · 1.2K reputation6y agoPosted Jul 16, 2020, 4:26 PM EDT+1Hi Nivi, Can you please share your code so that I can look into it and let you know+1
Sachin SinghRank #66 · 26.2K reputation6y agoPosted Jul 16, 2020, 4:54 PM EDT+1YourDbContext db=new YourDbContext();var yourEntity=db.yourDbSet.Any(x=>x.id); // i hope you are passing something like id to filter. YourTextbox.Text=YourEntity.Name ; // any property of your entity+1
Jignesh KumarRank #91 · 22.9K reputation6y agoPosted Jul 16, 2020, 6:36 PM EDT+1Hi Nivi, Use this link which will help you,https://www.c-sharpcorner.com/article/entity-framework-basic-guide-to-perform-fetch-filter-insert-update-and-dele/ +1
GUGuest UserRank #3,979 · 374 reputation6y agoPosted Jul 16, 2020, 8:43 PM EDT+1Hi...Here is my code.. aspx(design) <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Profile.aspx.cs" Inherits="WalPaper.WebForm4" %> User Profile Name: UserName: EmailID: Password: Confirm Password: onclick="Button1_Click" /> <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Profile.aspx.cs" Inherits="WalPaper.WebForm4" %> User Profile Name: UserName: EmailID: Password: Confirm Password: onclick="Button1_Click" /> aspx.. using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WalPaper{ public partial class WebForm4 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { { WallpaperEntities3 context = new WallpaperEntities3(); string Id = Request.QueryString["Id"]; // string UserName = TxtUserName.Text; var query = (from c in context.Users where TxtUserName.Text == c.UserName select new { c.Name, c.UserName, c.EmailID, c.Password, c.Confirm_Password }).FirstOrDefault(); if (query != null) { TxtName.Text = query.Name; TxtUserName.Text = query.UserName; TxtEmailID.Text = query.EmailID; TxtPassword.Text = query.Password; TxtConfirmPassword.Text = query.Confirm_Password; } } } } protected void Button1_Click(object sender, EventArgs e) { } }}+1Jenith ThakkarRank #789 · 2.9K reputation6y agoPosted Jul 16, 2020, 9:27 PM EDT+1Hi NiviI read your code it seems like okayPlease update here what kiind of error throwing Thank you+1GUGuest UserRank #3,979 · 374 reputation6y agoPosted Jul 16, 2020, 9:52 PM EDT+1hi aashima khatoon, when i use ur senerio its throe this exception... LINQ to Entities does not recognize the method 'System.String ToString(System.Object)' method, and this method cannot be translated into a store expression. +1GUGuest UserRank #3,979 · 374 reputation6y agoPosted Jul 16, 2020, 10:36 PM EDT+1Thank you so much aashima khatoon +1Atul WaradeRank #1,357 · 1.2K reputation6y agoPosted Jul 15, 2020, 6:29 PM EDT0Hi Nivi, Please go through below URL it might help you https://www.youtube.com/watch?v=kSFkF4TVDIs0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jenith ThakkarRank #789 · 2.9K reputation6y agoPosted Jul 16, 2020, 9:27 PM EDT+1Hi NiviI read your code it seems like okayPlease update here what kiind of error throwing Thank you+1
GUGuest UserRank #3,979 · 374 reputation6y agoPosted Jul 16, 2020, 9:52 PM EDT+1hi aashima khatoon, when i use ur senerio its throe this exception... LINQ to Entities does not recognize the method 'System.String ToString(System.Object)' method, and this method cannot be translated into a store expression. +1
GUGuest UserRank #3,979 · 374 reputation6y agoPosted Jul 16, 2020, 10:36 PM EDT+1Thank you so much aashima khatoon +1
Atul WaradeRank #1,357 · 1.2K reputation6y agoPosted Jul 15, 2020, 6:29 PM EDT0Hi Nivi, Please go through below URL it might help you https://www.youtube.com/watch?v=kSFkF4TVDIs0
Sachin SinghRank #66 · 26.2K reputationPosted Jul 16, 2020, 10:16 PM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jul 16, 2020, 9:13 PM EDT
Santhakumar MunuswamyRank #128 · 17.3K reputationPosted Jul 15, 2020, 5:49 PM EDT
Guest UserRank #3,979 · 374 reputationPosted Jul 16, 2020, 9:05 AM EDT
Santhakumar Munuswamy,
Guest UserRank #3,979 · 374 reputationPosted Jul 16, 2020, 9:06 AM EDT
Atul Warade,,
Santhakumar MunuswamyRank #128 · 17.3K reputationPosted Jul 16, 2020, 9:06 AM EDT
Atul WaradeRank #1,357 · 1.2K reputationPosted Jul 16, 2020, 4:26 PM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jul 16, 2020, 4:54 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Jul 16, 2020, 6:36 PM EDT
Guest UserRank #3,979 · 374 reputationPosted Jul 16, 2020, 8:43 PM EDT
User Profile
User Profile
Jenith ThakkarRank #789 · 2.9K reputationPosted Jul 16, 2020, 9:27 PM EDT
I read your code it seems like okay
Please update here what kiind of error throwing
Thank you
Guest UserRank #3,979 · 374 reputationPosted Jul 16, 2020, 9:52 PM EDT
aashima khatoon,
Guest UserRank #3,979 · 374 reputationPosted Jul 16, 2020, 10:36 PM EDT
aashima khatoon
Atul WaradeRank #1,357 · 1.2K reputationPosted Jul 15, 2020, 6:29 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts