当前位置:编程学习 > C#/ASP.NET >>

GridView 中的LISTBOX问题

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GroupMapping.aspx.cs" Inherits="GroupMapping"  EnableEventValidation="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <link href="tableclass.css" rel="stylesheet" type="text/css" />  
    <title>Group Mapping</title>
   <script type="text/javascript">
 <!--
function Mv(a,b) {
var i = 0;
var f=document.getElementById(a);
var t=document.getElementById(b);
for(var i=0; i<f.options.length; i++) {
if(f.options[i].selected ) {
var no = new Option();
no.value = f.options[i].value;
no.text = f.options[i].text;
t.options[t.options.length] = no;
}
}
Rv(a);
}
function Rv(o) {
var o=document.getElementById(o);
for(var i=o.options.length-1; i>=0; i--) {
if(o.options[i].selected && o.options[i] != "") {
 o.options[i].value = "";
 o.options[i].text = "";
 o.options[i] = null;
 }
}
}



-->
</script> 
</head>

<body>
    <form id="form1" runat="server" >
    <div>
        <br />
        <br />
        <br />
        <br />
        <table style="width: 89px; height: 178px" align=center>
            <tr>
                <td rowspan="2" style="width: 42px">
                    大组<asp:ListBox ID="SltAddrA" runat="server" Height="217px" Width="198px" SelectionMode="Multiple"  DataTextField=label DataValueField=choiceid></asp:ListBox></td>
                <td style="width: 13px; height: 82px;">
                    <br />
                    <br />
                    <input id="Button1" type="button" value=">>>"  onClick="Mv('SltAddrA','SltAddrB');" />
                    <input id="Button2" type="button" value="<<<"  onClick="Mv('SltAddrB','SltAddrA');" /></td>
                    <td style="width: 47px; height: 82px">
                        一组<br />
                    <asp:ListBox ID="SltAddrB" runat="server" Height="90px" Width="124px" SelectionMode="Multiple"></asp:ListBox></td>
            </tr>
            <tr>
                <td style="width: 13px; height: 85px;">
                    <br />
                    <br />
                    <input id="Button4" type="button" value=">>>" onClick="Mv('SltAddrA','SltAddrC');" />
                    <input id="Button3" type="button" value="<<<" onClick="Mv('SltAddrC','SltAddrA');" /></td>
                    <td style="width: 47px; height: 85px;">
                        二组<br />
                    <asp:ListBox ID="SltAddrC" runat="server" Height="94px" Width="127px" SelectionMode="Multiple"></asp:ListBox></td>
            </tr>
            
        </table>
        <asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns=false>
          <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:ListBox ID="G100004" runat="server">
                           
                        </asp:ListBox>
                        <input id="BTA100004" type="button" value="button11"  onclick="Mv('SltAddrA','???????')"/>//这个地方的动态id怎么取啊???????????
                        <input id="BTB100004" type="button" value="button22"  />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        
        </asp:GridView>
             
     
    
    </div>
       
    
    </form>
</body>
</html>
上面我用普通的listbox可以完成两个框的数据互动,当我改用gridview动态生成的listbox时onclick中的id怎么写啊???请教高手!! --------------------编程问答-------------------- 可以在数据绑定的时候加atribute的属性
用代码实现 --------------------编程问答-------------------- 能不能讲清楚点啊??我是初学者. --------------------编程问答-------------------- 有没有高手会啊!!!!! --------------------编程问答-------------------- 有人会吗?/??? --------------------编程问答-------------------- GridView 的 PreRender 方法中 

for i = 0 to gridview1.rows.count -1
   ctype(gridview1.rows(i).findcontrol("listboxID"),listbox).atribute.add("onclick","js Mothod")
 
next --------------------编程问答-------------------- 说的详细一点,好吗?分不够我可以加
!!谢谢!!1
--------------------编程问答-------------------- 代码太长,要试才知道,懒得看 --------------------编程问答-------------------- Control.ID
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,