【问题标题】:To create a gridview and update the table with the given details创建网格视图并使用给定的详细信息更新表格
【发布时间】:2013-02-20 10:00:11
【问题描述】:

我希望在表格中更新用户提供的详细信息,例如姓名、地址..等,并在网格视图中显示。

这样我就可以在 gridview 本身中编辑/更新

string s = Session["something"].ToString();
            string str=string.Empty;

        //bool bNextResult;
        SqlConnection con = new SqlConnection("server=AMRNDHW1995\\DEV1;UID=POMS_ZOETIS_D_RO;PWD=12Werty@; database=POMS_Zoetis_D;");

        SqlCommand cmd = new SqlCommand("select amount from budget_detail where year='" + s + "'", con);
        SqlDataReader dr;
        con.Open();
        dr = cmd.ExecuteReader();
        SqlDataAdapter da = new SqlDataAdapter(cmd);



        //DataSet ds =new DataSet();
        //da.Fill(ds);


        //while (bNextResult == true)
        //{

        while (dr.Read())
        {

            str += dr.GetValue(0).ToString()               
                +"\n"; 

【问题讨论】:

  • 请澄清您的问题。你想达到什么目标?

标签: c# sql gridview


【解决方案1】:
DataRow DR = dtTable.NewRow();
DR["Name"]=TxtName.Text;
DR["Age"]=TxtAge.Text;
DR["Place"]=TxtPlace.Text;
dtTable.adtTable.Rows.Add(DR);
dataGridView1.DataSource = dtTable;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 2012-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多