I have encountered a strange problem with Dynamic Data based solution. PLEASE HELP!
Here is a snapshot of the Database:
I have 2 tables, Element - (ElementID PrimaryKey,GroupID Foreignkey] , StateGroup (StateID PrimaryKey, GroupID ForiengKey) which derive their respective GroupID values from Parent Group Table.
I am using Linq2Sql and I have extended the solution to include the Clone Functionality for rows in each table.
My ControlExtension.cs Looks Like this:
//Some great soul posted this piece of code ...//
public static Control FindControlRecursive(this Control Root, string Id)
{
if (Root.ClientID.IndexOf(Id) > 0) return Root;
foreach (Control Ctl in Root.Controls)
{
Control FoundCtl = FindControlRecursive(Ctl, Id);
if (FoundCtl != null)
return FoundCtl;
}
return null;
}
public static IOrderedDictionary ExtractObjecValues(this Control control, MetaTable table)
{
OrderedDictionary retval = new OrderedDictionary();
if (control.GetType().Name.Contains("FormView"))
{
foreach (var column in table.Columns)
{
var colValue = FindControlRecursive(control, column.Name) as IBindableControl;
retval.Add(column.Name, null);
if (colValue != null) colValue.ExtractValues(retval);
}
return retval;
}
}
When I Clone StateGroup Table Row , colvalue for MetaForeignKey Group is {ASP.dynamicdata_fieldtemplates_text_ascx} , hence it doesnot populate GroupID column is table. Thus the clone functionality fails.
however, When I Clone Element Table Row , colvalue for MetaForeignKey Group is {ASP.dynamicdata_fieldtemplates_foriegnkey_Edit_ascx} , hence it populate GroupID column is table. Thus the clone functionality works.
There is no custom code differences in these 2 tables. I am not able to understand why it renders Group Field as text for StateGroup Table and foreignkey_Edit for Element Table
I have been stuck with this problem for 2 days, and the only difference that i have noticed is the name of the table itself - which is very weird.
Thank you for your reply, I have emailed you the sample code and screenshots at your email address from your blog. I am eagerly waiting for your response...
Can someone please take a look into this issue and advice? I have the code sample and screenshots to recreate the bug, how can i attach it to this thread?
I am sending you another email in a few minutes, I realized that there was an extra line of code with the project I sent you earlier. Sorry about that. I wanted to send you the code that was only relevant to recreate the bug and while removing the extra
code, there was an oversight.
I apologize again for this and will send you a version shortly.
wininblue
Member
22 Points
19 Posts
Problem with rendering a Foreign Key
Jan 05, 2012 02:40 PM|LINK
Dear Gurus,
I have encountered a strange problem with Dynamic Data based solution. PLEASE HELP!
Here is a snapshot of the Database:
I have 2 tables, Element - (ElementID PrimaryKey,GroupID Foreignkey] , StateGroup (StateID PrimaryKey, GroupID ForiengKey) which derive their respective GroupID values from Parent Group Table.
I am using Linq2Sql and I have extended the solution to include the Clone Functionality for rows in each table.
My ControlExtension.cs Looks Like this:
//Some great soul posted this piece of code ...//
public static Control FindControlRecursive(this Control Root, string Id)
{
if (Root.ClientID.IndexOf(Id) > 0) return Root;
foreach (Control Ctl in Root.Controls)
{
Control FoundCtl = FindControlRecursive(Ctl, Id);
if (FoundCtl != null)
return FoundCtl;
}
return null;
}
public static IOrderedDictionary ExtractObjecValues(this Control control, MetaTable table)
{
OrderedDictionary retval = new OrderedDictionary();
if (control.GetType().Name.Contains("FormView"))
{
foreach (var column in table.Columns)
{
var colValue = FindControlRecursive(control, column.Name) as IBindableControl;
retval.Add(column.Name, null);
if (colValue != null) colValue.ExtractValues(retval);
}
return retval;
}
}
When I Clone StateGroup Table Row , colvalue for MetaForeignKey Group is {ASP.dynamicdata_fieldtemplates_text_ascx} , hence it doesnot populate GroupID column is table. Thus the clone functionality fails.
however, When I Clone Element Table Row , colvalue for MetaForeignKey Group is {ASP.dynamicdata_fieldtemplates_foriegnkey_Edit_ascx} , hence it populate GroupID column is table. Thus the clone functionality works.
There is no custom code differences in these 2 tables. I am not able to understand why it renders Group Field as text for StateGroup Table and foreignkey_Edit for Element Table
I have been stuck with this problem for 2 days, and the only difference that i have noticed is the name of the table itself - which is very weird.
PLEASE HELP!
Thank you,
wininblue
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: Problem with rendering a Foreign Key
Jan 05, 2012 07:42 PM|LINK
Hi Wininblue, can you give access to a sample with the bug so I cna repro and test? (you can get my e-mail from my blog)
Always seeking an elegant solution.
wininblue
Member
22 Points
19 Posts
Re: Problem with rendering a Foreign Key
Jan 05, 2012 08:42 PM|LINK
Hi Steve,
Thank you for your reply, I have emailed you the sample code and screenshots at your email address from your blog. I am eagerly waiting for your response...
thanks,
wininblue
wininblue
Member
22 Points
19 Posts
Re: Problem with rendering a Foreign Key
Jan 09, 2012 01:49 PM|LINK
Hi,
Can someone please take a look into this issue and advice? I have the code sample and screenshots to recreate the bug, how can i attach it to this thread?
Really appreciate any help I can get on this.
Thank you,
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: Problem with rendering a Foreign Key
Jan 10, 2012 10:32 AM|LINK
Hi Wininblue, I am looking at your sample now, shyould have an answer later
Always seeking an elegant solution.
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: Problem with rendering a Foreign Key
Jan 10, 2012 10:45 AM|LINK
Hi Wininblue, I have tested the sample you sent but none of your entities will clone so I cannot see the issue.
Always seeking an elegant solution.
wininblue
Member
22 Points
19 Posts
Re: Problem with rendering a Foreign Key
Jan 10, 2012 01:08 PM|LINK
Hi Steve,
Thanks for taking the time to test the code.
You can clone the record by doing the following:
1: Select Table, once on the table page, scroll down to the form View that is per record
2: Select "Edit/Clone Record" option
3: It opens the Form View in edit mode, and there you have an option of Cloning the Record.
I apologize for missing out these steps in the first place.
Regards,
wininblue
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: Problem with rendering a Foreign Key
Jan 10, 2012 01:38 PM|LINK
I tried that on each table and nothing happend no errors at all but it also did not clone :(
Always seeking an elegant solution.
wininblue
Member
22 Points
19 Posts
Re: Problem with rendering a Foreign Key
Jan 10, 2012 01:50 PM|LINK
Steve,
I am sending you another email in a few minutes, I realized that there was an extra line of code with the project I sent you earlier. Sorry about that. I wanted to send you the code that was only relevant to recreate the bug and while removing the extra code, there was an oversight.
I apologize again for this and will send you a version shortly.
Regards,wininblue
sjnaughton
All-Star
27330 Points
5459 Posts
MVP
Re: Problem with rendering a Foreign Key
Jan 10, 2012 02:02 PM|LINK
so the bug is with Group? if I debug that I will see your issue?
Always seeking an elegant solution.