回发前在gridview中保存临时信息
我有一个对话框(模态),我将在其中注册一个(或多个)联系人。
联系人将转到网格视图,可以在其中对其进行编辑或删除。
Gridview中的数据只能在进程结束时保存在数据库中。
我怎样才能实现这个目标?
模态代码
$(function () {
$(".ModalBox").dialog({
autoOpen: false,
height: 400,
resizable: false,
draggable: false,
width: 602,
modal: true,
open: function (type, data) {
$(this).parent().appendTo($("form:first"));
}
});
});
OBS:
我没有很好的 CSharp 或 html 代码示例,因为我不知道如何实现这一点。我的所有代码看起来都很混乱(已经尝试了很多事情)
我的 GridView 是一个 ascx,模态在同一个 ascx 中。
我我相信一些临时表,或者类似的东西会有帮助,但我从来没有做过类似的事情(看起来像购物车软件),而且我什至不知道如何寻找它。
谢谢。如果你能做一些代码示例,那就太好了。
编辑: 我做了这段代码:
CSharp代码:
[Serializable]
public class TabelaTempContato
{
public int IDCliente { get; set; }
public string Nome { get; set; }
public string Email { get; set; }
public string Telefone { get; set; }
public string Cpf { get; set; }
public string Rg { get; set; }
public string Departamento { get; set; }
public string Cargo { get; set; }
}
protected List ListaTabelaTemp
{
get
{
if (this.ViewState["TabelaTemp"] == null)
{
this.ViewState["TabelaTemp"] = new List();
}
return (List)this.ViewState["TabelaTemp"];
}
}
protected void AddItem()
{
this.ListaTabelaTemp.Add(new TabelaTempContato());
this.gvContato.DataSource = this.ListaTabelaTemp;
this.gvContato.DataBind();
}
protected void btnTest_Click(object sender, EventArgs e)
{
this.AddItem();
}
我创建了一个临时网格视图,但数据是空的,我尝试从模式中的文本中提取它,但我无法做到,我是我'我不熟悉如何将数据从 gridview 获取到数据库。 (我相信这是更容易的部分,然后我现在没有关注它)
编辑:我用我的解决方案创建答案。
I have a Dialog (Modal), where I'll register one (or several) contact.
the contact goes to a gridview, where they may be edited or deleted.
the data in the Gridview, can only be saved in the database at the end of the process.
How can I achieve this?
Modal code
$(function () {
$(".ModalBox").dialog({
autoOpen: false,
height: 400,
resizable: false,
draggable: false,
width: 602,
modal: true,
open: function (type, data) {
$(this).parent().appendTo($("form:first"));
}
});
});
OBS.:
I don't have a good sample of CSharp or html code, 'cuz i don't know how to achieve this. All my code look messy atm (trying a lot of things already)
My GridView is an ascx, and the modal is in the same ascx.
I belive some temporary table, or something like this will help, but i never did something like it (looks like a shop cart software), and i don't even know how look for it.
Thank you. if you can do some code sample, it will be GREAT.
EDIT:
i did this code:
CSharp code:
[Serializable]
public class TabelaTempContato
{
public int IDCliente { get; set; }
public string Nome { get; set; }
public string Email { get; set; }
public string Telefone { get; set; }
public string Cpf { get; set; }
public string Rg { get; set; }
public string Departamento { get; set; }
public string Cargo { get; set; }
}
protected List ListaTabelaTemp
{
get
{
if (this.ViewState["TabelaTemp"] == null)
{
this.ViewState["TabelaTemp"] = new List();
}
return (List)this.ViewState["TabelaTemp"];
}
}
protected void AddItem()
{
this.ListaTabelaTemp.Add(new TabelaTempContato());
this.gvContato.DataSource = this.ListaTabelaTemp;
this.gvContato.DataBind();
}
protected void btnTest_Click(object sender, EventArgs e)
{
this.AddItem();
}
i create one temporary gridview, but the data is empty, i tried pull it from my text in the modal, but i was not able to, i'm i'm not familiar in how i'll get the data from gridview to my database. (i believe this is the easier part, then i not focused at it in the moment)
EDIT: I create the answer with my solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在我从模态中获取值!现在只需要几件事(我相信)。
1-获取数据库中的数据以首次加载 GridView(如果是版本),并加载新的临时数据。
2- 保存新的临时数据。
完成:
1-我加载我的视图状态并使用它来加载网格。
2-还使用我的视图状态在数据库中保存我的数据。
Now i get the values from my modal! Just need a couple of things now (i belive).
1- Get the data in my database to load the GridView for the first time (if it's an edition), and load with the new temp data.
2- Save the new temp data.
DONE:
1- i load in my viewstate and use it to load the grid.
2- also using my viewstate to save my data, in the database.