日期:2014-05-17 浏览次数:20901 次
<asp:gridview runat="server" AutoGenerateColumns="False" Width="100%" ID = "gridview1"
runat="server">
<Columns>
<asp:TemplateField HeaderText="题号">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="序号" HeaderText="序号" SortExpression="序号" />
</Columns>
</asp:gridview>
gridview1.DataSource = ds;
gridview1.DataBind();
TextBox tb;
for (int i = 0; i <= gridview1.Rows.Count - 1; i++)
{
tb = (TextBox)gridview1.Rows[i].FindControl("TextBox1");
tb.Text = ds.Tables[0].Rows[i][0].ToString();
}
TextBox tb;
string nos = ""; //题目题号
string Question_id = "";//题目序号
for (int i = 0; i < gridview1.Rows.Count; i++)
{
tb = (TextBox)gridview1.Rows[i].FindControl("TextBox1");
nos = tb.Text.ToString();
Question_id = gridview1.Rows[i].Cells[1].Text.ToString();
Response.Write("<script>alert('"+nos.ToString()+","+Question_id+"')</script>");
}