Small tricky Linq2SQl insert operation (dynamic user management and page insert)
I'm actually trying to do this, but I can't seem to find a way.
here is the scenario, I got a blog module that I made for my clients because it is a repetitive task, so I only need to upload it to a new client and he can start blogging, but some clients need additional custom fields, say he wants add a phone number for each article author or sitelink, but I don't want to implement it for each client because it's a custom requirement.
Now for this I thought about creating a dynamic custom control with this extra feed and this code in the custom control like
Blog bl = new Blog();
bl.ExtraRefrence = " http://www.something.com";
upload it to blog dashboard, but I want user to be able to control the data context on the main blog edit page, I mean the main page will have an insert command, so how can I pass the command to insert the main page, see dynamic the value of the custom control without creating 2 blog objects, one in the page and one in the custom control.
Sorry if I don't know, but seriously this is killing me.
source to share
Option 1
Make the field customizable.
Pseudocode:
if client.HasExtraReference() then
<asp:label text="<%= client.ExtrareferenceLabel %>" />
<asp:textbox id="txtExtraReference" />
end if
and in the code
Blog bl = new Blog();
bl.Content = ...
....
if client.HasExtraReference() then
bl.ExtraRefrence = txtExtraReference.text;
end if
The method HasExtraReference
might show you some configuration.
Option 2
If you have multiple additional and variable fields, you can add the ExtraBlogItem table.
BlogExtraItem
-------------
BlogExtraItemID int
BlogID int
ItemName Varchar(50)
ItemValue Varchar(250)
Add the elements you want to the page and then pass a single parameter List( Of BlogExtraItem )
to the Blog.Insert function
source to share