Hi all.,

Some we may feel some what un comfort with out grid view., Off-course its a best control to display the data in a formatted way. Suppose if we have more columns or more fields to display in a grid view. we feel that its a not easy task to display the data with out browser scrolling.

At that time we will think about to hide some data that means some text from a column., like only displaying the first few characters.

Yes that's the good option to follow.

It can be done using a simple conditional Operator ( ? ).

<asp:TemplateField HeaderText="Business">
<asp:TextBox ID="gvtxtBussName" width="80px" runat="server" Text='<%# Bind("BusinessName") %>' ValidationGroup="upd"></asp:TextBox>

<asp:Label ID="Label4" runat="server" Width="80px" Font-Size="10px"
Text='<%# Eval("BusinessName").ToString().Length > 10 ? Eval("BusinessName").ToString().Substring(0, 10)+".." : Eval("BusinessName") %>' ToolTip='<%# Bind("BusinessName") %>' ></asp:Label>

<ItemStyle Wrap="True" HorizontalAlign="Left" Width="80px" />
<HeaderStyle HorizontalAlign="Left" />

In the above code I would like to display Bussiness name in my grid view., it compulsory to my requirement. at this case i reduced the characters to First 10.

Like this we can display content as we wish with simple modifications.

Enjoy this Delicious dish.

If you have any Query or doubts regarding this please feel free to post comment or an Email.

See you again :)

Share it


Post a Comment