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_Gridview_Records_Rowdatabound - Fatal编程技术网

C# 如何将gridview中的记录标记为已读和未读

C# 如何将gridview中的记录标记为已读和未读,c#,asp.net,gridview,records,rowdatabound,C#,Asp.net,Gridview,Records,Rowdatabound,这是我的GridView1。我想突出显示最新的记录,在用户单击授权号(哪个用户在下一页查看了该记录)后,该行将不会突出显示(表示用户查看该记录后,该行恢复正常,无突出显示,无粗体字体) 我目前的进展是,, 我已在数据库中创建了名为ReadStatus的新位字段,默认为0 接下来,我需要进行onrowdatabound编码以实现这一点 第一个问题是,当我读取所有列时,是否需要读取位列(ReadStatus)?授权号、产品ID、名称、数量、--(ReadStatus)?? 我应该阅读此代码中的Rea

这是我的GridView1。我想突出显示最新的记录,在用户单击授权号(哪个用户在下一页查看了该记录)后,该行将不会突出显示(表示用户查看该记录后,该行恢复正常,无突出显示,无粗体字体)

我目前的进展是,, 我已在数据库中创建了名为ReadStatus的新位字段,默认为0 接下来,我需要进行onrowdatabound编码以实现这一点

第一个问题是,当我读取所有列时,是否需要读取位列(ReadStatus)?授权号、产品ID、名称、数量、--(ReadStatus)?? 我应该阅读此代码中的ReadStatus吗

           / /READING RECORD FROM TABLE TRACK_ITEM
            while (reader.Read())
            {
                MerchantProduct merchantProduct = new MerchantProduct();
                merchantProduct.TxID = reader["TxID"].ToString();
                merchantProduct.ProductID = reader["ProductID"].ToString();
                merchantProduct.Name = reader["ProductName"].ToString();
                merchantProduct.Qty = Convert.ToInt32(reader["Qty"]);

                listLatestProduct.Add(merchantProduct);
            }
            return listLatestProduct;
第二个问题是,有人能告诉我在onrowdatabound中编码的正确方法吗

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
           //Tried many code here but none is working 
    }

谢谢。

首先,您需要在ur db中为ReadStatus(1/0)再添加一列, 然后将make作为aspx页面中的hiddenfield

               <asp:TemplateField HeaderText="ReadStatus" Visible="false">
                                              <ItemTemplate>
                                                      <asp:Label ID="readStatus" runat="server"></asp:Label>
                                                      <asp:HiddenField ID="readStatusHiddenField" runat="server" Value='<%#Eval("ReadStatus") %>'/>
                                                  </ItemTemplate>
                                              </asp:TemplateField>

您可以绑定SelectionChangedEvent并交换数据库中的可见性值。OnSelectedIndexChanged设置值。。位0表示未读,位1表示已读,然后为BindyourGrid.。)对不起,你能进一步解释一下吗?我没有收到uok manish让我试试n我会让你知道你能发布你的网格绑定代码吗?还有您在aspx页面中添加的网格。我将修改它们并返回给您。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    // searching through the rows
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        int reading = Convert.ToInt32(((HiddenField)e.Row.FindControl("readStatusHiddenField")).Value);
        if (reading == 0)
        {
            e.Row.BackColor = Color.LightGray;
            e.Row.Font.Bold = true;
        }
    }
}