如何在数据库中存储模板? [英] How to store template in database?

查看:132
本文介绍了如何在数据库中存储模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个关于学习管理系统的演示项目。我有一个表来存储所有问题,这些问题将在创建测试时使用。现在我想为问题文件构建一个模板。例如

I am building a demo project on Learning Management System. I have a table to store all questions,those questions will be used while creating tests. Now I want to build a template for question paper. e.g

--------------- Template to be stored in database -------------
(m=marks,n=no of questions)

Name of the Template = Template1

1. Five short questions (m=1xn=5)   Total = 5
2. Three descriptive type questions (m=2xn=3) Total = 6
.
.
---------------- End Template----------------------------------





现在将来当用户选择该模板时,即Template1则1.将从表中提取五个问题标记将从模板中获取。 2.将提取三个描述性问题,并从模板中获取标记。



我正在使用asp.net Web表单构建此项目。需要帮助来创建这种场景。



我尝试过:



我没有任何线索,如何为这种情况设计表?



Now in future when user select that template i.e Template1 then 1. five questions will be fetched from table and marks will be fetched from template. 2. Three descriptive questions will be fetched and marks will be fetched from template.

I am building this project using asp.net Web forms. Help needed to create this kind of scenario.

What I have tried:

I don't have any clue , how to design table for this scenario?

推荐答案

你可以有一个nvarchar(max)数据类型的列,你可以存储模板的HTML表单。

这些模板中将包含占位符,将在代码或存储过程中替换为实际值。



模板示例

You can have a column of nvarchar(max) datatype and you can store the HTML form of the template.
These template will have placeholders in it, which will be replaced with actual value either in code or in stored procedure.

template example
{firstName}
{firstName}





稍后代码



tmeplate.Replace({firstName},你的价值);



later on in code

tmeplate.Replace("{firstName}","your value");


这篇关于如何在数据库中存储模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆