Garima Bansal

Garima Bansal

  • 1.1k
  • 559
  • 29.5k

show text instead of value in gridview

Mar 10 2023 10:52 AM

I have a gridview that gets the data from a database and it has SectorId, name,mobile 

But in Database table SectorId is save in Value and i want text in Gridview on pageload

<asp:GridView ID="grdtrack" runat="server" AutoGenerateColumns="false" AllowPaging="true" PageSize="10" Visible="false">
    <Columns>
        <asp:BoundField HeaderText="Id" DataField="Id" Visible="false" />
        <asp:BoundField ItemStyle-Width="150px" DataField="Name" HeaderText="Name" />
        <asp:BoundField ItemStyle-Width="150px" DataField="Mobile_No" HeaderText="Mobile No" />
        <asp:BoundField ItemStyle-Width="150px" DataField="SectorId" HeaderText="Grievance Sector" />
        <asp:BoundField ItemStyle-Width="150px" DataField="Details" HeaderText="Remarks" />
        <asp:TemplateField HeaderText="Action">
            <ItemTemplate>
                <asp:LinkButton ID="lnk_View" Text="View" CommandArgument='<% #Eval("Id") %>' runat="server" />
            </ItemTemplate>

        </asp:TemplateField>
    </Columns>
</asp:GridView>

 


Answers (6)