Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在gridview中获取可编辑的复选框字段_C#_Asp.net_Sql - Fatal编程技术网

C# 在gridview中获取可编辑的复选框字段

C# 在gridview中获取可编辑的复选框字段,c#,asp.net,sql,C#,Asp.net,Sql,我正在从SQLServer存储过程填充gridview。我的目标是使一个复选框字段在gridview中可编辑,我的意思是当gridview显示一条记录时,复选框字段(IsComplaint)在每一行中都应该是可编辑的,并且应该反映在数据库中 protected void btnSearchByDate_Click(object sender, EventArgs e) { DateTime fromDate = DateTime.ParseExact(txtFromDat

我正在从SQLServer存储过程填充gridview。我的目标是使一个复选框字段在gridview中可编辑,我的意思是当gridview显示一条记录时,复选框字段(IsComplaint)在每一行中都应该是可编辑的,并且应该反映在数据库中

protected void btnSearchByDate_Click(object sender, EventArgs e)
    {
        DateTime fromDate = DateTime.ParseExact(txtFromDate.Text, "dd/MMM/yyyy", null);
        DateTime toDate = DateTime.ParseExact(txtToDate.Text, "dd/MMM/yyyy", null);
        DataTable dt = ManageQueueBizz.GetSmsComplaintsByDate(fromDate, toDate);

        if (dt.Rows.Count > 0)
        {

            GridViewSmsComplaints.DataSource = dt;
            GridViewSmsComplaints.DataBind();
            GridViewSmsComplaints.Visible = true;
            //gridViewComplaintsBySubject.Visible = false;
        }
        else
        {

            dt.Rows.Add(dt.NewRow());
            GridViewSmsComplaints.DataSource = dt;
            GridViewSmsComplaints.DataBind();
            int totalcolums = GridViewSmsComplaints.Rows[0].Cells.Count;
            GridViewSmsComplaints.Rows[0].Cells.Clear();
            GridViewSmsComplaints.Rows[0].Cells.Add(new TableCell());
            GridViewSmsComplaints.Rows[0].Cells[0].ColumnSpan = totalcolums;
            GridViewSmsComplaints.Rows[0].Cells[0].Text = "No Data Found";
            GridViewSmsComplaints.Visible = true;
            //gridViewComplaintsBySubject.Visible = false;

        }
    }
.aspx代码:

<asp:GridView ID="gridViewComplaintsByDate" AllowPaging="true"  AutoGenerateSelectButton="true" runat="server" CssClass="mGrid"  Width="408px" OnPageIndexChanging="gridViewComplaintsByDate_PageIndexChanging" OnSelectedIndexChanged="gridViewComplaintsByDate_SelectedIndexChanged">
             <EmptyDataRowStyle BorderStyle="None" ForeColor="Red" BorderWidth="0px" />
             <EmptyDataTemplate>
               No Data Found for this Input. Try Again.
             </EmptyDataTemplate> 
             <SelectedRowStyle CssClass="selected-row"  ForeColor="white" />
           </asp:GridView>
           <br />
        </asp:Panel>
        </div>

找不到此输入的数据。再试一次。


您的数据库中有bool吗?嗯,我会定义网格中的每一列,并为每一行绑定每个字段。对于bool字段,选中其值并相应地设置复选框。