日期:2014-05-18  浏览次数:20810 次

新手求教,子窗口获得父窗口数据问题
因工作原因,小弟第一次学做网页,效果是查询到数据后进行修改的功能
用showModalDialog弹出修改子窗口,界面是一竖排的TextBox对应父窗口GridView的一行
想要弹出是对其需要的修改每个TextBox默认显示出GridView的数据
对于web还处于新手学习阶段,很多基础的知识都不清楚,只能摸索着学习了,
该如何实现呢
附上GridView的创建代码,是不是可以按照newrow.Cell[i]和tcRow[j]进行对应啊?
C# code

protected void GridView1_RowCreated( object sender , GridViewRowEventArgs e )
    {
        TableCellCollection tcRow = e.Row.Cells;

        switch(e.Row.RowType)
        {
            case DataControlRowType.Header:

                GridViewRow newrow=new GridViewRow(0,0, DataControlRowType.Header,DataControlRowState.Normal);
                newrow.Visible=true;

                for(int i=0;i<tcRow.Count;i++)
                {
                    TableCell tc=new TableCell();
                    tc.Text=tcRow[i].Text;
                    tc.VerticalAlign=VerticalAlign.Middle;
                    tc.HorizontalAlign=HorizontalAlign.Center;
                    newrow.Cells.Add(tc);
                }

                newrow.Cells[0].RowSpan=2;
                newrow.Cells[1].RowSpan=2;
                newrow.Cells[2].RowSpan=2;
                newrow.Cells[3].RowSpan=2;
                newrow.Cells[4].RowSpan=2;
                newrow.Cells[5].ColumnSpan=2;
                newrow.Cells.RemoveAt(6);
                newrow.Cells[6].RowSpan=2;
                newrow.Cells[7].ColumnSpan=2;
                newrow.Cells.RemoveAt(8);
                newrow.Cells[8].ColumnSpan=2;
                newrow.Cells.RemoveAt(9);
                newrow.Cells[9].ColumnSpan=2;
                newrow.Cells.RemoveAt(10);
                newrow.Cells[10].ColumnSpan=2;
                newrow.Cells.RemoveAt(11);
                newrow.Cells[11].RowSpan=2;
                newrow.Cells[12].RowSpan=2;

                tcRow[0].Text="Min";
                tcRow[1].Text="Max";
                tcRow[2].Text="Min";
                tcRow[3].Text="Max";
                tcRow[4].Text="Min";
                tcRow[5].Text="Max";
                tcRow[6].Text="Min";
                tcRow[7].Text="Max";
                tcRow[8].Text="Min";
                tcRow[9].Text="Max";

                for ( ; tcRow.Count > 10; )
                {
                    tcRow.RemoveAt( 10 );
                }

                GridView1.Controls[0].Controls.AddAt(0,newrow);
                break;
                
            case DataControlRowType.DataRow:
                break;
        }
}


------解决方案--------------------
可以把GRIDVIEW中的ID传过去,执行查询赋值。
也可以把选中的条的对象传过去,进行赋值。