Hi There,
I have apparently a simple requirement. I have one table, named "TBL_MYDATA" in SQL DB. The table is as below...
ID : INT : PK : Identity (1,1)
DID : VARCHAR(10) : Computed column : "DID" + RIGHT("00000" + CAST(ID AS varchar(5)) , 5)
Name: VARCHAR(100) NOT NULL
ADDRESS: VARCHAR(200) NULL
Now I have created a page with gridview which shows data correctly and then on click of each row, "Edit" screen is also opening correctly, and that Edit Page is showing two fields.. i.e. NAME & ADDRESS.
~ Upto here it's all good. Now when I am editing any field, Name or Address and trying to hit save then I'm getting error
Upon further investigation in SQL Profiler, I noticed that the way Update SQL is generated from Radzen Edit page is as below,
So, here I could see that the update statement is trying to update "ID" column, which is a primary key. Obviously, this statement is causing the failure.
How can I prevent such thing? I do not want update statement generated from the "FORM" view to try updating any Primary key column or computed column etc. But in Radzen IDE, I couldn't find such option anywhere. Kindly could someone give me some guidance please?
Thanks @enchev
In my Edit page also, ID column (Which is a Primary Key and Identity) and DID (which is a computed column) is not present. So I assumed UI looked good. Only when I found it is not letting me do the update then I look help of SQL Profiler to see what actually is getting fired in SQL side and then only I am noticing that the SQL code behind is creating a statement that includes ID update (as the sql I shared).
So, my question was, is there a way I can explicitly define what to not update.
Thanks for responding @enchev
Unfortunately, nothing abnormal in model... I am just a bit lost what's going on here.
[Table("MY_TBLDATA", Schema = "Common")]
public partial class CommonMYTBLDATA
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID
{
get;
set;
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public string DID
{
get;
set;
}
[ConcurrencyCheck]
public string NAME
{
get;
set;
}
[ConcurrencyCheck]
public string ADDRESS
{
get;
set;
}
}
Unfortunately I don't (Yet). I am evaluating this product and possibly if it suits our purposes (my users are great Excel Fan... so they like to see how best we can provide a grid that is almost excel like, and whether they can drag a comment on multiple rows etc. to update.... lol )
But I am very far from it yet and struggling at the basics.
By the way... I noticed on my first post, I wrote a typo.
The ID is identity auto increment column. But this is not a PK....
Actual PK is DID column.
Could that give us some hint why program is trying to update ID column? If yes then how could we avoid such?
I mean to be honest... my question is even more generic.... If for some reason I have a few calculated column etc. which I don;t want to update from UI, how do I do so here?