我使用字符串构建器和sql中的数据创建了一个动态表,每行包含一个按钮,我必须在ajax中显示该行数据 [英] I have created a dynamic table using string builder and data from sql and each row consists of a button and i have to show that row data in ajax
本文介绍了我使用字符串构建器和sql中的数据创建了一个动态表,每行包含一个按钮,我必须在ajax中显示该行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void Button1_Click(object sender, EventArgs e)
{
StringBuilder st = new StringBuilder();
st.AppendLine("<table>");
st.AppendLine("<tr>");
st.AppendLine("</tr>");
con.Open();
string sqlQuery = "spread ";
SqlCommand cmd = new SqlCommand(sqlQuery, con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader sdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
if (sdr.HasRows)
{
sdr.Read();
dt.Load(sdr);
int i = 0;
foreach (DataColumn dc in dt.Columns)
{
i++;
st.AppendLine("<tr><td>");
st.AppendLine("" + dc.ToString());
st.AppendLine("</td></tr>");
}
st.AppendLine("");
foreach (DataRow dr in dt.Rows)
{
st.AppendLine("<tr>");
int k = 0;
do
{
st.AppendLine("<td>");
// On this dynamic button i have to fetch the data of the particular row in ajax modalpopupextender
st.AppendLine("<input type=submit id= " + k + dr[k].ToString() + " name=" + k + dr[k].ToString() + " runat="server" value=" + dr[k].ToString() );
st.AppendLine("</td>");
k++;
} while (k < dt.Columns.Count);
st.AppendLine("</tr>");
}
}
st.AppendLine("</table>");
Literal1.Text = st.ToString();
}
推荐答案
所以你想要一个jquery脚本来完成这项工作。这样做你需要任何帮助吗?
SO you want a jquery script to do that job. Do you need any help in doing that?
这篇关于我使用字符串构建器和sql中的数据创建了一个动态表,每行包含一个按钮,我必须在ajax中显示该行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文