I’m only in my second month as a professional developer and this is my first time posting, so please forgive any errors!
I’m working with asp.net and I have created a grid view as below. When Status text is set to a particular status I want to cover all of the cells, apart from the status text, in that row with a warning.
The data comes from an MQ string and is managed by a separate class. I’m thinking that a row databound event might be the way to go. I’m thinking something like the code below
Gridview:
<asp:GridView runat="server" ID="gridDisc" GridLines="none" AutoGenerateColumns="false" CellPadding="2" HeaderStyle-backColor="#CCEEFF" OnRowDataBound="gridDisc_RowDataBound" ><AlternatingRowStyle CssClass="ep1" /> <Columns> <asp:BoundField DataField="StatusText" /> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblPartDesc" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Qty" /> <asp:BoundField DataField="UOI" /> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblStockDetails" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:Label ID="lblDealerInv" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Listprice" /> <asp:BoundField DataField="DiscCode" /> <asp:BoundField DataField="OptiInd" /> <asp:BoundField DataField="Weight" /> <asp:BoundField DataField="ExchangeSurcharge" /> </Columns> </asp:GridView>
Code behind:
protected void gridDisc_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
PartEnquiryLine line = (PartEnquiryLine)e.Row.DataItem;
Label lbl = (Label)e.Row.FindControl(“lblStatusDetails”);
if (line.StatusText == Text[“280”])
{
lbl.Text = Text[“290”]
}
But I haven’t been able to find any guidance on how to create a label that would cover specific cells in that row when triggered. I may be way off with this, but how would I do it?
#c-sharp #asp.net