SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["conn"].ToString());
string strfrom="Product_Sort";
string strSql="select SortName from "+strfrom;
ds=new DataSet();
tool.demand(conn,ds,strfrom,strSql);
conn.Close();
dt=ds.Tables[0];
for(int i=0;i<=dt.Rows.Count-1;i++)
{

string Strjavascript=@"<div id='KB"+(i+1).ToString()+@"Parent' class=parent>
<a href='#' onClick=expandIt('KB"+(i+1).ToString()+@"'); return false><img src=file:///C:\Inetpub\wwwroot\fstcs\folder1.gif border=0>"+dt.Rows[i].ToString()+@"</a></div>";

ds=new DataSet();
string samllfrom="Product_SmallSort";
string smallSql="select ProductName from "+samllfrom+" WHERE (Sortcode = " + n +")";
tool.demand(conn,ds,samllfrom,smallSql);
conn.Close();
for(int j=0;j<=ds.Tables[0].Rows.Count-1;j++)
{

//Strjavascript+=@"<div id='KB"+(j+1).ToString()+ "Child' class=child onclick=\"alert(top.mainFrame.TextBox17.Text)\">";
Strjavascript+=@"<div id='KB"+(j+1).ToString()+ "Child' class=child onclick=\"top.mainFrame.document.all.TextBox17.Text=\'" + ds.Tables[0].Rows[j].ToString() + "'\">";
Strjavascript+=@"<a href=MainPage.aspx target=mainFrame><img src=img/list.gif border=0 alt='' width=15 height=11><img src=file:///C:\Inetpub\wwwroot\fstcs\file.gif border=0>"+ds.Tables[0].Rows[j].ToString()+"</a><br></div>";
}
RegisterStartupScript("startup"+n,Strjavascript);
n++;
}-----------------------------------------------------------------------------------------
问题:
1、ds.Tables[0].Rows[j].ToString() 监测出是行的对象````
2、Strjavascript+=@"<div id='KB"+(j+1).ToString()+ "Child' class=child onclick=\"top.mainFrame.document.all.TextBox17.Text=\'" + ds.Tables[0].Rows[j].ToString() + "'\">";怎么不能把值传到框架页面的SERVER控件上?
3、FOR的嵌套循环自认没有什么问题```可以为什么循环的就是不对`````
呜`````````请高手解答,我要急死了```下面是客户端的JAVASCRIPT代码
-----------------------------------------------------------------------------------------
<script language="JavaScript">
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;if (ver4) {
    with (document) {
        write("<STYLE TYPE='text/css'>");
        if (NS4) {
            write(".parent {position:absolute; visibility:visible}");
            write(".child {position:absolute; visibility:visible}");
            write(".regular {position:absolute; visibility:visible}")
        }
        else {
            write(".child {display:none}")
        }
        write("</STYLE>");
    }
}function getIndex(el) {
    ind = null;
    for (i=0; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.id == el) {
            ind = i;
            break;
        }
    }
    return ind;
}function arrange() {
    nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;
    for (i=firstInd+1; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.visibility != "hide") {
            whichEl.pageY = nextY;
            nextY += whichEl.document.height;
        }
    }
}function initIt(){
    if (!ver4) return;
    if (NS4) {
        for (i=0; i<document.layers.length; i++) {
            whichEl = document.layers[i];
            if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
       }
        arrange();
    }
    else {
        divColl = document.all.tags("DIV");
        for (i=0; i<divColl.length; i++) {
            whichEl = divColl(i);
            if (whichEl.className == "child") whichEl.style.display = "none";
        }
    }
}function expandIt(el) {
    if (!ver4) return;
    if (IE4) {
        whichEl = eval(el + "Child");
        if (whichEl.style.display == "none") {
            whichEl.style.display = "block";
        }
        else {
            whichEl.style.display = "none";
        }
    }
    else {
        whichEl = eval("document." + el + "Child");
        if (whichEl.visibility == "hide") {
            whichEl.visibility = "show";
        }
        else {
            whichEl.visibility = "hide";
        }
        arrange();
    }
}
onload = initIt;
</script>
</FONT> 
<!---->
<P><FONT face="宋体"><asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 120px; POSITION: absolute; TOP: 132px"
runat="server" Height="236px" Width="436px"></asp:datagrid></FONT></P>
<script language="JavaScript">
if (NS4) {
        firstEl = "KB1Parent";
        firstInd = getIndex(firstEl);
        arrange();
}
</script>
----------------------------------------------------------------------------------------

解决方案 »

  1.   

    ds.Tables[0].Rows[j].ToString() -> ds.Tables[0].Rows[j][你要的字段名].ToString()
      

  2.   

    我是来UP一下再要分的...柳哥哥。。记得给我一D分哟... haha....
      

  3.   

    2. 
    top.mainFrame.document.all.TextBox17.Text=\'" + ds.Tables[0].Rows[j].ToString() 
    头尾最好加上<SCRIPT>..
    ds.Tables[0].Rows[j].ToString()   这个取值错了
    top.mainFrame.document.all.TextBox17.value
                                          ~~~~~~~
      

  4.   

    楼上同学`
    头尾最好加上<SCRIPT>..
    我是后台注册客户端代码(.CS里面写HTML代码),所以不需要<Script>
    ----------------------------------------------
    top.mainFrame.document.all.TextBox17.value
    我是把数据库提取出来的值传带框架另个PAGE的SERVER控件里面``该控件没有value,所以就算传过去了,也不能接收。我的问题是``我的值传不过去```猜想有可能是接收的是SERVER控件(不确定)
    -----------------------------------------------------------
    ds.Tables[0].Rows[j].ToString()   这个取值错了
    恩``这个我知道,为吸引人``白丢的10分。不管怎么样`谢谢你!一定给分你!