<Columns>
<asp:TemplateField HeaderText="Actions" ItemStyle-Width="15%">
<ItemTemplate>
<asp:ImageButton ID="imgbtn" ImageUrl="Styles/Images/Edit.jpg" runat="server" Width="25"
Height="25" OnClick="imgbtn_MessageEditClick" Enabled="True" ToolTip="Edit Message" />
<asp:LinkButton ID="Lnk_Delete" CommandArgument='<%# Eval("MsgID") %>'
CommandName="Delete" runat="server" > <img id="Img1" src="Styles/Images/Delete.jpg" runat="server" style="border-style: none"
alt="Delete Message" /></asp:LinkButton>
<asp:ImageButton ID="imgbtn_ViewDashBoard" ImageUrl="Styles/Images/dash.jpg" Enabled="True"
Width="" runat="server" PostBackUrl='<%# Eval("MsgID", "ResponseMetric.aspx?MsgID={0}") %>'
Text='Send' ToolTip="View DashBoard"></asp:ImageButton>
</ItemTemplate>
我有这些项目模板,它们在同一列中,我还有另一列 MessageActive。如果messageActive 为 no,那么我将行颜色设置为红色,对于同一列,rowDataBound
我如何在.disable
ImageButton ID="imgbtn"
asp:LinkButton ID="Lnk_Delete"
ItemTemplate
protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
System.Web.UI.WebControls.Image img = (System.Web.UI.WebControls.Image)e.Row.FindControl("Status");
int msgid;
int.TryParse(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MsgID")), out msgid);
string status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MessageActive"));
if(status.Equals("No"))
{
e.Row.BackColor = Color.Red;
}
}
}
我databind
为gridview
.