Customizing ItemState

My ItemState property of the GridView displays lots of characters.
I want to display only the first 60 characters (but the EditItemState
property should display all the characters). Where should I write the
code, in HTML view or in Code-behind file

In HTML view I tried both Remove() and Substring() methods, but
both did not work.

How can I get only the first 60 characters in ItemState

Advance Thanks.




Answer this question

Customizing ItemState

  • An De Lafonteyne

    create a method in your code like:-

    protected string WhateverYouWantToCallThis! (string strIn)

    {

    return strIn.Length<60 strIn: strIn.SubString(0, 60);

    }

    Then in you data grid turn the column into a template column, edit the item one and change it to custom databinding, then add WhateverYouWantToCallThis!(Eval("ItemState"))

    This should work - syntax might not be 100%, let me know if you need anymore help.

    Ross



  • Senthil Nathan.S

    In the other way ,I think you can set the column

    dataGridView1.Columns.Insert(0, New DataGridViewTextBoxColumn)

    ' Modify the first column

    With dataGridView1.Columns(0)

    ' Don't allow the column to be resizable.

    .Resizable = DataGridViewTriState.False

    ' Make the check box column frozen so it is always visible.

    .Frozen = True

    ' Put an extra border to make the frozen column more visible

    .Width = 60

    .Readonly=true

    End With

    maybe it will show the characters you want



  • Customizing ItemState