Can you help me help you by stubbing out a sample result query that reproduces the issue?
I started to stub out KitapOkuyorum class so you can continue until you can reproduce your view without an actual database query. There are some fields missing and I am sure you can come up with better dummy sample values than I can. :)
Here is a copypaste of your
<script>
block, initiating the stub out of the class. I believe that with this I will be able to run your sample here and try what is not working for you.
If it sounds too much like trouble for you, I believe you can flat out the results and simplify your model (without submodels in it -- like in Country and Region). For example, by instead of bringing
COUNTRY { ID, NAME }
, showing it just as
COUNTRY_ID, COUNTRY_NAME
.
I also suspect that the problem may be in this sub-model declaration. Instead of a model with two entities inside, you could directly reference the model items, but to ensure that I would have to be able to run the sample here with a good stub of the results you get on a query.
<script runat="server">
public class KitapOkuyorum
{
public class Model
{
public class UserInfo
{
public int ID;
public string USER_NAME;
public string FIRST_NAME;
public string LAST_NAME;
public int PAY;
public int ACTIVE;
public string LAST_LOGIN;
public Country COUNTRY;
public Region REGION;
}
public class Country
{
public int ID;
public string NAME;
}
public class Region
{
public int ID;
public string NAME;
}
public class dbEntities : IDisposable
{
public List<UserInfo> USER;
// Fill the list with dummy data.
public dbEntities()
{
// Just three entries, you might feel like adding more (say, 10, 20) dummy entries.
USER = new List<UserInfo>() {
new UserInfo() {
ID = 20, USER_NAME = "user1", FIRST_NAME = "Robert", LAST_NAME = "Wickinson",
PAY = 20, ACTIVE = 1, LAST_LOGIN = DateTime.Now.ToString(),
COUNTRY = new Country() { ID=1, NAME="Singapore" },
REGION = new Region() { ID=1, NAME="Complex A" }
},
new UserInfo() {
ID = 21, USER_NAME = "user2", FIRST_NAME = "Athens", LAST_NAME = "Moondust",
PAY = 20, ACTIVE = 1, LAST_LOGIN = DateTime.Now.ToString(),
COUNTRY = new Country() { ID=2, NAME="Chile" },
REGION = new Region() { ID=4, NAME="Complex G" }
},
new UserInfo() {
ID = 1, USER_NAME = "admin", FIRST_NAME = "Jan", LAST_NAME = "Stanley",
PAY = 20, ACTIVE = 1, LAST_LOGIN = DateTime.Now.ToString(),
COUNTRY = new Country() { ID=3, NAME="Japan" },
REGION = new Region() { ID=3, NAME="Oriental Junction" }
}
};
}
public void SaveChanges()
{
X.AddScript("console.log('All changes would have been saved at this point.');");
}
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
using (KitapOkuyorum.Model.dbEntities db = new KitapOkuyorum.Model.dbEntities())
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = db.USER.ToList();
this.Store1.DataBind();
}
}
}
protected void Edit(int UserId)
{
Response.Redirect("/admin/edit/user-" + UserId);
}
protected Field OnCreateFilterableField(object sender, ColumnBase column, Field defaultField)
{
if (column.DataIndex == "ID")
{
((TextField)defaultField).Icon = Icon.Magnifier;
}
return defaultField;
}
//burada hata var
public void DeleteSelected(int[] idArray)
{
using (KitapOkuyorum.Model.dbEntities db = new KitapOkuyorum.Model.dbEntities())
{
foreach (int item in idArray)
{
db.USER.Remove(db.USER.FirstOrDefault(x => x.ID == item));
db.SaveChanges();
}
}
}
</script>