Hello and thanks for reading this.
Is there some way that I can databind my Repeater to list only the rows that contains somethings that equal a word/number from my QueryString?
Here is an Example of my Nav Url with a QueryString in it : /Store.aspx?id=12
Can I bind the repeater to Load all rows where the Column is equal to 12
private void BindItems()
{
rpStore.DataSource = Menues.GetAll();
rpStore.DataBind();
}
My Menues.cs Class:
public static List<Item> GetAll()
{
using (Scooterfrøen_Entities db = new Scooterfrøen_Entities())
{
return db.Item.ToList();
}
}
Btw I'm using Entity FrameWork, so a solution with that is prefence but not needed.
Thanks alot.
Create a function like this:
public static List<Item> GetById(int id)
{
using (Scooterfrøen_Entities db = new Scooterfrøen_Entities())
{
var listOfItemsById = from i in db.Item
where i.Id == id
select i;
return listOfItemsById.ToList();
}
}
When the page loads in store.aspx get the id :
int id = Convert.ToInt32(Request.QueryString["id"]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.