views:

62

answers:

2

Currently I'm writing an ASP.net webforms app, which works with a table containing 15 fields. I'm using LINQ to SQL which is very good to use and everything, but when i need to bind the fields with the text boxes (15 of em), whats the best way currently I'm doing this

...
...
var stud = db.Students.SingleOrdefault(d => d.ApplicationNo = 32)
textbox1.Text = stud.Name;
...
...

I feel like I'm "missing the point". Please advise on the best way to do this.

  • Also what should i do to implement the Move next and move previous functionality like a recordset

i mean how can i move to the next/previous "student" in db.Students collection.

A: 

You can use the Skip and Take method.

Update after comment:

You don't have to iterate through the different properties of the retrieved Student object. They're simply there. So you could use it like this:

txtName.Text = stud.Name;
txtAge.Text = stud.Age.ToString();

...

If you want to iterate to another record you can use the Skip and Take methods.

Grz, Kris.

XIII
I don't understand quite clearly. for eg: After i find a record based on a id such a ApplicationNo, how can i move next of that particular record ?
Vivek Bernard
+1  A: 

Hey,

You can bind to an ASP.NET DetailsView control; this control supports displaying one record at a time, and can page through the results, so you don't have to do all that extra work. You could also consider a FormView too, but you have to control that.

I think you have the right approach; you could also use ElementAt() to retrieve by an index; that can have some performance implications though.

HTH.

Brian