这个问题不难,就是复杂点
用viewstate或session缓存你的dataset
多行同时编辑用js实现多行联动
比如价钱变了后比例、总数等也要变,当然是用js不提交变化快
要不老闪客户会烦的我实现它用了一天半,加上查msdn学js的时间
用viewstate或session缓存你的dataset
多行同时编辑用js实现多行联动
比如价钱变了后比例、总数等也要变,当然是用js不提交变化快
要不老闪客户会烦的我实现它用了一天半,加上查msdn学js的时间
解决方案 »
- form表单验证admin文件夹...
- 关于如果做MD5加密的问题,新手!谢谢!
- .net mv3 怎么样上传音乐视频文件?
- assembly怎么用?比如下面,说我重复了?
- ASPNET如何调用客户端程序,比如“计算器”?
- 典型的排列组合问题,首选回溯法问题
- 关于索引值超出范围!!!高分求解,来者有分!!!
- 如何生成2维的动态数组
- e.Item.Cells[1].Controls[1]) 和e.Item.FindControl("ID"))有什么区别?FindControl如何使用呀
- 初学者问题:我正在安装vs.net,第三步要不要安了?在线,急!
- 再问一下,在.net中,longraw类型的数据如何转换成byte[]类型读出?谢谢!
- 读取数据库问题
关键要用到uniqueid这个东西
客户端肯定是用js来做计算,但是如何同时编辑这些数据,然后相互之间按一定的关系得到结果?
能做到点击编辑后所有的行处于编辑状态,然后修改某行中某个值,其他的都跟着变化吗?
另外还要个问题,按某个字段分组.你有空可以看看我的demo.谢谢!
<input type="hidden" id="EditNum">
<table>
<repeat id="myrepeat" Runat="server">
<ItemTemplate>
<tr>
<td id="t0<%#DataBinder.Eval(Container.DataItem, "ID")%>">要显示的值</td>
<td><a onclick="editRow('<%#DataBinder.Eval(Container.DataItem, "ID")%>">','要显示的值')">修改</a></td>
<tr>
</ItemTemplate>
</repeat>
</table>js:
function editRow(m,n)
{
var aa = parseInt(document.all("EditNum").value);
aa++;
document.all("t0"+m).innerHTML="<input type='text' id='a1"+aa+"' value='"+n+"'>";
}然后你提交修改的时候,先获取hidden里的数,如果是3的话,就代表有三行被修改,然后用循环
for(int i=0;i<取到的行数;i++)
{
string _abc = Request.Form["a1"+i.tostring()];
保存到数据库
}重点就是hidden 框中的数字,点修改要+1,如果恢复不修改某行,一定要-1
这样就可用bcje这个用uniqueid处理过的id区别前台显示时候同一控件在每行的不同id
从而能被script处理
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
TextBox txt=(TextBox) e.Item.FindControl("txtbcje");
if ( txt!=null)
{
//several onchange Js
string bcje = e.Item.UniqueID + "_"+"txtbcje";
bcje = bcje.Replace(":","_");
((TextBox)e.Item.FindControl("txtbcje")).Attributes.Add("onkeyup","calcje(bcje);");
}
}
}
最后的bcje就成了前台这个控件每行的ID
感谢,也感谢大家,给了我这么多提示,我应该能搞定了.谢谢!
js有for in
vbs有for each
都能循环了
用C#循环就更简单了
private void dgmargin_ItemDataBound(object sender, C1ItemEventArgs e)
{
(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
TextBox textbox1=(TextBox)e.Item.FindControl("TextBox1");
TextBox textbox2=(TextBox)e.Item.FindControl("TextBox2");
TextBox textbox3=(TextBox)e.Item.FindControl("TextBox3");
TextBox textbox4=(TextBox)e.Item.FindControl("TextBox4");
TextBox textbox5=(TextBox)e.Item.FindControl("TextBox5");
TextBox textbox6=(TextBox)e.Item.FindControl("TextBox6");
if(textbox1!=null&&textbox2!=null&&textbox3!=null&&textbox4!=null&&textbox5!=null&&textbox6!=null)
{
string tb1=e.Item.UniqueID+"_"+"TextBox1";
tb1=tb1.Replace(":","_");
string tb2=e.Item.UniqueID+"_"+"TextBox2";
tb2=tb2.Replace(":","_");
string tb3=e.Item.UniqueID+"_"+"TextBox3";
tb3=tb3.Replace(":","_");
string tb4=e.Item.UniqueID+"_"+"TextBox4";
tb4=tb4.Replace(":","_");
string tb5=e.Item.UniqueID+"_"+"TextBox5";
tb5=tb5.Replace(":","_");
string tb6=e.Item.UniqueID+"_"+"TextBox6";
tb6=tb6.Replace(":","_");
string script1="<script language='javascript'>";
script1+="function function_"+tb1+"(){";
script1+="var form=document.Form1;";
script1+="var sellprice=form."+tb3+".value;";
script1+="var qty=form."+tb1+".value;";
script1+="document.Form1."+tb4+".value=sellprice*qty;";
script1+="}</script>";
Page.RegisterStartupScript(tb1,script1);
((TextBox)e.Item.FindControl("TextBox1")).Attributes.Add("onkeyup","function_"+tb1+"()");
}
}
}
这段东西产生了预料中的客户端,其中一段:
<input name="dgmargin:R0:Textbox1" type="text" value="4" id="dgmargin_R0_Textbox1" class="textbox" onkeyup="function_dgmargin_R0_TextBox1()" style="width:50px;" /><script language='javascript'>function function_dgmargin_R0_TextBox1(){var form=document.Form1;var sellprice=form.dgmargin_R0_TextBox3.value;var qty=form.dgmargin_R0_TextBox1.value;document.Form1.dgmargin_R0_TextBox4.value=sellprice*qty;}</script>但触发dgmargin_R0_Textbox1的onkeyup事件总是提示说dgmargin_R0_Textbox1.value为空或不室对象,为何?谢谢