批量插入Access数据库不适用于gridview中的模板字段 [英] Bulk Insert into Access Database not working for template fields in gridview

查看:90
本文介绍了批量插入Access数据库不适用于gridview中的模板字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Button1_Click(object sender, EventArgs e)
   {
       foreach (GridViewRow gvrow in GridView1.Rows)
       {
            string sid = gvrow.Cells[0].Text;
           RadioButtonList rbAtt = (RadioButtonList)GridView1.Rows[selectedIndex].FindControl("rbAtt");
           con.Open();
           SqlCommand cmd = new SqlCommand("InsertAttendence", con);
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Parameters.AddWithValue("@StudentId", sid);
           if (dlAtt.SelectedItem.Text=="Morning")
           {
               cmd.Parameters.AddWithValue("@Morning", rbAtt.SelectedValue);
           }
           else
           {
               cmd.Parameters.AddWithValue("@Morning", DBNull.Value);
           }
           if (dlAtt.SelectedItem.Text=="Evening")
           {
               cmd.Parameters.AddWithValue("@Evening", rbAtt.SelectedValue);
           }
           else
           {
               cmd.Parameters.AddWithValue("@Evening", DBNull.Value);
           }

           cmd.ExecuteNonQuery();
           con.Close();
       }

   }


我在单选按钮插入时遇到错误,任何人都可以帮我...


I got the error at radio button insertion any one Could you pls help me...

推荐答案

尝试使用rbAtt.Text希望对您有所帮助

祝你好运...........
try to use rbAtt.Text hope this helps

Best of luck...........


这篇关于批量插入Access数据库不适用于gridview中的模板字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆