如何将动态创建的控制值存储到数据库中? [英] How to store the dynmaic created control values into database?

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

问题描述


我想将动态创建的文本框值存储到数据库中,请帮帮我!!!!

Hi,
I want to store the dynamically created textbox values into the database pls help me!!!!

推荐答案

cshtml:
cshtml:
<table  id="mainTbl" class="table-hover table12">
                                        <thead>
                                            <tr>
                                                <td class="timezone1">
                                                    <strong>Holiday Names</strong>
                                              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <strong>Dates</strong>
                                                </td>
                                            </tr>
                                        </thead>

                                        <tr class="BindDDLClass">

                                            <td>

                                               <input type="text" id="HolidayName" />

                                                <input type="text" class="datetext" id="date123"/></td>

                                        </tr>





                                    </table>



控制器:

[HttpPost]
公共JsonResult SLAHolidayDay(字符串HolidayName,字符串Year,字符串Date)
{
int result = 0;

RequestSVCRef.RequestServiceClient requestServiceClient =新的RequestSVCRef.RequestServiceClient();
SLAholidayScheduleVM objSLAHoliday =新的SLAholidayScheduleVM();


result = requestServiceClient.InsertHolidayDetails(HolidayName,Convert.ToInt32(Year),Convert.ToDateTime(Date));


如果(结果!=空)
{
return Json(new {error =已添加列表中的假日"});
}
其他
{
return Json(new {error =假期未添加列表"));
}
}


jQuery的:



controller:

[HttpPost]
public JsonResult SLAHolidayDay(string HolidayName, string Year, string Date)
{
int result=0;

RequestSVCRef.RequestServiceClient requestServiceClient = new RequestSVCRef.RequestServiceClient();
SLAholidayScheduleVM objSLAHoliday = new SLAholidayScheduleVM();


result = requestServiceClient.InsertHolidayDetails(HolidayName, Convert.ToInt32(Year), Convert.ToDateTime(Date));


if (result != null)
{
return Json(new { error = "Holidays in the list is added" });
}
else
{
return Json(new { error = "Holidays not added list" });
}
}


jquery:


(" span>).live(' 点击',函数(){ var
("#BtnAdd").live('click', function () { var


newInput =
newInput =


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

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