I am trying to display string with fixed length (say 10 Digits of strings) in Grid view item template while binding, i could not find any Format specifiers for the string itself.
i can get format specifiers for (Numbers{0:N}
, Floats & Decimal (D)
, Currency{0:C}
, , Date{1,8:yyyy}
, Percentage {0,3:P1}
,Temperature: {0:F}
, Exponential
, Hexadecimal
... But Not For String Itself)
I tried links: Click here but didn't work for me.
My Grid view have an Template Field (Item Template)
<asp:TemplateField HeaderText="Notes">
<ItemTemplate>
<asp:Label ID="Label_Note" runat="server" Text='<%# String.Format("{0}", Eval("Defect_Note").ToString()) %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
I need to display 'Notes Column' in below grid with max 10 digits. if exeeds it should not show (can show on tooltip) if less than 10 it can show all its content.
I wanted to display the Notes columns like Printf(" %8s" ,¬e)
in C#. (in Binding single line)
Don't forget to check for null values.