| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1012 人关注过本帖
标题:必须声明变量 '@kid'。
取消只看楼主 加入收藏
水晶心
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2010-7-27
结帖率:80%
收藏
已结贴  问题点数:20 回复次数:1 
必须声明变量 '@kid'。
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966" BorderStyle="None"
            BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1"
            onpageindexchanging="GridView1_PageIndexChanging" PageSize="5" Style="z-index: 109;
            left: 140px; position: absolute; top: 148px" Width="396px" HorizontalAlign="Left">
            <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
            <Columns>
                <asp:BoundField DataField="kid" HeaderText="考勤编号" ReadOnly="True" SortExpression="kid" />
                <asp:BoundField DataField="uid" HeaderText="用户编号" SortExpression="uid" />
                <asp:BoundField DataField="uname" HeaderText="用户姓名" SortExpression="uname" />
                <asp:BoundField DataField="kqdate" HeaderText="考勤日期" SortExpression="kqdate" />
                <asp:BoundField DataField="dgdate" HeaderText="到岗日期" SortExpression="dgdate" />
                <asp:BoundField DataField="sj" HeaderText="事假" SortExpression="sj" />
                <asp:BoundField DataField="bj" HeaderText="病假" SortExpression="bj" />
                <asp:BoundField DataField="gj" HeaderText="公假" SortExpression="gj" />
                <asp:BoundField DataField="kg" HeaderText="旷工" SortExpression="kg" />
                <asp:BoundField DataField="cq" HeaderText="出勤" SortExpression="cq" />
                <asp:BoundField DataField="hj" HeaderText="婚嫁" SortExpression="hj" />
                <asp:BoundField DataField="sj1" HeaderText="丧假" SortExpression="sj1" />
                <asp:BoundField DataField="gxj" HeaderText="干休假" SortExpression="gxj" />
                <asp:BoundField DataField="tqj" HeaderText="探亲假" SortExpression="tqj" />
                <asp:BoundField DataField="pc" HeaderText="陪产假" SortExpression="pc" />
                <asp:BoundField DataField="cc" HeaderText="出差" SortExpression="cc" />
                <asp:BoundField DataField="dx" HeaderText="倒休" SortExpression="dx" />
                <asp:CommandField ShowEditButton="True" />
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>
            <RowStyle BackColor="White" ForeColor="#330099" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
            <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:kqConnectionString %>"
            SelectCommand="SELECT [kid], [uid], [uname], [kqdate], [dgdate], [cq], [sj], [bj], [gj], [kg], [hj], [sj1], [gxj], [tqj], [pc], [cc], [dx] FROM [kaoqin]" DeleteCommand="DELETE FROM [kaoqin] WHERE [kid] = @kid" InsertCommand="INSERT INTO [kaoqin] ([kid], [uid], [uname], [kqdate], [dgdate], [cq], [sj], [bj], [gj], [kg], [hj], [sj1], [gxj], [tqj], [pc], [cc], [dx]) VALUES (@kid, @uid, @uname, @kqdate, @dgdate, @cq, @sj, @bj, @gj, @kg, @hj, @sj1, @gxj, @tqj, @pc, @cc, @dx)" UpdateCommand="UPDATE [kaoqin] SET [uid] = @uid, [uname] = @uname, [kqdate] = @kqdate, [dgdate] = @dgdate, [cq] = @cq, [sj] = @sj, [bj] = @bj, [gj] = @gj, [kg] = @kg, [hj] = @hj, [sj1] = @sj1, [gxj] = @gxj, [tqj] = @tqj, [pc] = @pc, [cc] = @cc, [dx] = @dx WHERE [kid] = @kid">
            
        </asp:SqlDataSource>





public partial class kqmanage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BindGrid();

    }
    private void BindGrid()
    {
        string str = ConfigurationSettings.AppSettings["dsn"];
        SqlConnection cn = new SqlConnection(str);
        cn.Open();
        String mysql = "select * from kaoqin";
        SqlDataAdapter da = new SqlDataAdapter(mysql, cn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataBind();
        cn.Close();

    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindGrid();//重新绑定记录
    }

   
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        //GridView gv = (GridView)sender;
        //string aa = e.RowIndex.ToString();
        //string id = gv.DataKeys[e.RowIndex].ToString();
    }

    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        this.GridView1.EditIndex = e.NewEditIndex;
        BindGrid();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

    }
    //当取消时触发
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        this.GridView1.EditIndex = -1;
        BindGrid();
    }
    protected void LinkButton8_Click(object sender, EventArgs e)
    {
        Response.Redirect("kamanageadd.aspx");

    }
   
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            int vardid = Convert.ToInt32(txt_kid.Text.ToString());
            Response.Redirect("kpmodify.aspx?kid=" + vardid);
        }
        catch
        {
            Response.Write("输入的编号不正确");
            Response.End();
        }

    }
}
数据更新不了怎么回事啊,请各位高手帮忙
搜索更多相关主题的帖子: kid 变量 声明 
2010-08-17 10:08
水晶心
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2010-7-27
收藏
得分:0 
怎么写代码啊,我是个菜鸟,对代码不太懂,现在在学习中,请教一下
2010-08-17 15:01
快速回复:必须声明变量 '@kid'。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019216 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved