Assuming you donβt have display values ββstored in the database, this is a way to implement part of the rendering. There might be a more convenient way to store search values, if someone could contribute, I would appreciate it.
I wrote this in notepad since I do not have Visual Studio on my machine. Sorry if there are syntax errors.
Markup:
<asp:Label ID="lblPriority" Text='<%# RenderPriority(DataBinder.Eval(Container.DataItem,"Priority")) %>' runat="server" />
code:
Protected Function RenderPriority(ByVal dbValue As Object) As String Dim strReturn as String = String.Empty If Not IsDbNull(dbValue) Then Dim intValue as Integer If Integer.TryParse(dbValue, intValue) Then Select Case intValue Case 0 strReturn = "not set" Case 1 strReturn = "low" Case 2 strReturn = "medium" Case 3 strReturn = "high" End Select Else strReturn = dbValue.ToString() End If End If Return strReturn End Function
Edit:
After reading your question again, I get the impression that you prefer not to write a specific function for this purpose on the code page. If so, you should probably store the rows you want to associate with the key values ββin the database, and pull them through the SQL statement. Or at least push functionality to the data access layer. In any case, ideally, the GridView column will be represented by the required row using the data source.
source share