Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.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_.net_Gridview - Fatal编程技术网

C# gridview中要显示在单选按钮中的布尔单元格的值

C# gridview中要显示在单选按钮中的布尔单元格的值,c#,asp.net,.net,gridview,C#,Asp.net,.net,Gridview,我在数据库中有一个Boolea(bit)值,我在2号单元格的网格视图中显示了它,如下所示 MyGrdView.SelectedRow.Cells[2] // for any row selected this cell have a boolean value 0 or 1 多视图控件中视图1中的GridView 我需要在另一个视图(view2)中,我可以在复选框中显示此值,因此,如果gridview中的布尔单元格为0,则选中该复选框,对于1,则不选中该复选框 ASP代码: <asp:U

我在数据库中有一个Boolea(bit)值,我在2号单元格的网格视图中显示了它,如下所示

MyGrdView.SelectedRow.Cells[2] // for any row selected this cell have a boolean value 0 or 1
多视图控件中视图1中的GridView

我需要在另一个视图(view2)中,我可以在复选框中显示此值,因此,如果gridview中的布尔单元格为0,则选中该复选框,对于1,则不选中该复选框

ASP代码:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
    <asp:MultiView ID="LocationsMultiView" runat="server" ActiveViewIndex="0">
        <asp:View ID="View1" runat="server">
            <div>
                <div class="EU_TableScroll" id="showData" style="display: block">
                    <table class="auto-style1">
                        <tr>
                            <td>
                                <asp:Button ID="Btn_ShowReminders" runat="server" Text="Show Reminders" OnClick="Btn_ShowReminders_Click" />

                                <asp:Button ID="Btn_EditReminder" runat="server" Text="Edit Reminder" Enabled="False" OnClick="Btn_EditReminder_Click" />

                                <asp:Button ID="Btn_RemoveReminder" runat="server" Enabled="False" OnClick="Btn_RemoveReminder_Click" Text="Delete Reminder" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Lbl_Error" runat="server"></asp:Label>
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <asp:GridView ID="Grd_Reminders" runat="server" CssClass="EU_DataTable" GridLines="Horizontal" OnSelectedIndexChanged="Grd_Reminders_SelectedIndexChanged">
                                    <Columns>
                                        <asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="Select" ShowHeader="True" Text="&gt;&gt;&gt;" />
                                    </Columns>
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                                    <ProgressTemplate>
                                        <asp:Image ID="Image1" runat="server" ImageUrl="~/img/ajax-loader.gif" />
                                    </ProgressTemplate>
                                </asp:UpdateProgress>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </asp:View>

        <asp:View ID="View2" runat="server">
            <table class="auto-style1">
                <tr>
                    <td colspan="3">
                        <asp:Label ID="Lbl_EditRemTitle" runat="server" Text="Edit Reminder"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Lbl_Edit_Title" runat="server" Text="Title"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="Txt_EditTitle" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ValidationGroup="g1" ControlToValidate="Txt_EditTitle">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Lbl_Edit_Content" runat="server" Text="Content"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="Txt_Edit_Content" runat="server"></asp:TextBox>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style2">
                        <asp:Label ID="Lbl_Edit_Desc" runat="server" Text="Description"></asp:Label>
                    </td>
                    <td class="auto-style2">
                        <asp:TextBox ID="Txt_Edit_Description" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </td>
                    <td class="auto-style2">&nbsp;</td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Lbl_Edit_TurnOn" runat="server" Text="Turn On"></asp:Label>
                    </td>
                    <td>
                        <asp:CheckBox ID="CheckBox1" runat="server" />

                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Lbl_Edit_Alw" runat="server" Text="Always"></asp:Label>
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Lbl_Edit_Public" runat="server" Text="Public"></asp:Label>
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Lbl_Edit_Radius" runat="server" Text="Radius"></asp:Label>
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="3">
                        <asp:Label ID="Lbl_Edit_Msg" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:UpdateProgress ID="UpdateProgress2" runat="server">
                        </asp:UpdateProgress>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <asp:Button ID="Button1" runat="server" Text="Save" ValidationGroup="g1" />
                        <asp:Button ID="Btn_Cancel_Edit" runat="server" OnClick="Btn_Cancel_Edit_Click" Text="Cancel" />
                    </td>
                </tr>
            </table>
        </asp:View>
    </asp:MultiView>
</ContentTemplate>
{ 位置Lo=新位置()


}

plz显示完整的标记和一些代码绑定网格的方式?在另一个视图(2)中,您是否使用相同的数据源在网格中显示这些单选按钮?使用ReadOnly=“true”添加一个
CheckBoxField
,我输入了孔代码,您可以看到我在Btn\u editEmlerance\u Click事件中所说的内容:CheckBox1.Checked=Convert.ToBoolean(Grd\u emlers.SelectedRow.Cells[8]);
public partial class webusercontrols_remindersctl : System.Web.UI.UserControl
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        if (Utilities.ReadFromCookie("logincookie", "user", Request) != null)
        {
            UserInfo UI = new UserInfo();
            string userNameOnWB = Request.Cookies["logincookie"]["user"];
        }

    }

 //   Btn_ShowReminders_Click(null, null);
}

protected void Grd_Reminders_SelectedIndexChanged(object sender, EventArgs e)
{
    Btn_RemoveReminder.Enabled = true;
    Grd_Reminders.SelectedRow.BackColor = Color.FromName("#E56E94");
    Btn_RemoveReminder.Enabled = true;
    Btn_EditReminder.Enabled = true;
}


protected void Btn_ShowReminders_Click(object sender, EventArgs e)
{
    Locations loc = new Locations();
    string UserName = Request.Cookies["logincookie"]["user"];
    Grd_Reminders.DataSource = loc.GetRemindersForUser(UserName);
    Grd_Reminders.DataBind();
    Grd_Reminders.SelectedIndex = -1;
    Btn_RemoveReminder.Enabled = false;
    Btn_EditReminder.Enabled = false;
    Lbl_Error.Text = String.Empty;
}

protected void Btn_RemoveReminder_Click(object sender, EventArgs e)
{
    int ID = Int32.Parse((Grd_Reminders.SelectedRow.Cells[1].Text).ToString());

    if (Lo.RemoveLocations(ID))
    {
        Lbl_Error.Text = "Reminder Removed!";
    }
    else
    {
        Lbl_Error.Text = "Error Removing Reminder!";
    }

    Btn_RemoveReminder.Enabled = false;
    Grd_Reminders.DataBind();
}

protected void Btn_EditReminder_Click(object sender, EventArgs e)
{

    LocationsMultiView.ActiveViewIndex = 1;
    if (Grd_Reminders.SelectedRow.Cells[5] != null)
    Txt_EditTitle.Text = Grd_Reminders.SelectedRow.Cells[5].Text;

    if (Grd_Reminders.SelectedRow.Cells[6] != null)
    Txt_Edit_Content.Text = Grd_Reminders.SelectedRow.Cells[6].Text;

    if (Grd_Reminders.SelectedRow.Cells[7] != null)
    Txt_Edit_Description.Text = Grd_Reminders.SelectedRow.Cells[7].Text;

    if (Grd_Reminders.SelectedRow.Cells[8] != null)
    CheckBox1.Checked = Convert.ToBoolean(Grd_Reminders.SelectedRow.Cells[8]);
}

protected void Btn_Cancel_Edit_Click(object sender, EventArgs e)
{
    LocationsMultiView.ActiveViewIndex = 0;
}