我用动态添加Table里面的行列同时也向里面加载了TextBox文本框!
for (int i = 2; i < 10; i++)
{
TableRow tempRow = new TableRow();
TableCell tempCell1 = new TableCell();
tempRow.Cells.Add(tempCell1);
tempCell1.Text="awsdf"; for (int j = 1; j < 4; j++)
{
TableCell tempCell = new TableCell();
TextBox myddl = new TextBox();
myddl.ID="T"+Convert.ToString(i)+"M"+Convert.ToString(j);
tempCell.Controls.Add( myddl);
myddl.Text="sdfwsdf";
tempRow.Cells.Add(tempCell);
//string tt=((TextBox)FindControl("T"+i+"M"+j)).Text.Trim();
string tt1=((TextBox)FindControl("T2M1")).Text.Trim();
Table3.Rows.Add(tempRow); }
程序就像上面那样!
//string tt=((TextBox)FindControl("T"+i+"M"+j)).Text.Trim();
string tt1=((TextBox)FindControl("T2M1")).Text.Trim();
我上面两句不知道错在那里?都提示:未将对象引用设置到对象的实例。小弟不知道问题在那?我是想取得某个TextBox里的值.请高手帮忙!
for (int i = 2; i < 10; i++)
{
TableRow tempRow = new TableRow();
TableCell tempCell1 = new TableCell();
tempRow.Cells.Add(tempCell1);
tempCell1.Text="awsdf"; for (int j = 1; j < 4; j++)
{
TableCell tempCell = new TableCell();
TextBox myddl = new TextBox();
myddl.ID="T"+Convert.ToString(i)+"M"+Convert.ToString(j);
tempCell.Controls.Add( myddl);
myddl.Text="sdfwsdf";
tempRow.Cells.Add(tempCell);
//string tt=((TextBox)FindControl("T"+i+"M"+j)).Text.Trim();
string tt1=((TextBox)FindControl("T2M1")).Text.Trim();
Table3.Rows.Add(tempRow); }
程序就像上面那样!
//string tt=((TextBox)FindControl("T"+i+"M"+j)).Text.Trim();
string tt1=((TextBox)FindControl("T2M1")).Text.Trim();
我上面两句不知道错在那里?都提示:未将对象引用设置到对象的实例。小弟不知道问题在那?我是想取得某个TextBox里的值.请高手帮忙!
放到Table3.Rows.Add(tempRow);应该就可以了,控件没有加入到集合中
string tt1=myddl.Text.Trim();这样不知道到底是取那个值啊!
ice_frank(NULL) 不明白你的意思!