C1GridView edit cell customer format

Originally Posted 8 March 2013, 4:58 am EST

  • Originally Posted 8 March 2013, 4:58 am EST

    Hi, friends,

    About the tablecell editor, I need your's help.

    I need the following functions:

    1?The user can only enter integer
    2?When the user input is finished, the tablecell display custom format.
    For example, enter '123456 ' display '123, 456'.
    When the cell into edit mode, the value changes as '123456'

    Thanks,
    Davis Lee
  • Reply

    Hello Davis,

    C1GridView displays the values in the format you want by default if you use a C1BoundField.
    If you're using a C1TemplateField and wish to achieve the same, you'd need to handle the RowDataBound event and set the text with the desired format. Please take a look at the code below :

    <wijmo:C1TemplateField HeaderText="Quantity">
    <ItemStyle HorizontalAlign="Right" />
    <ItemTemplate>
    <asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("Quantity") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox runat="server" ID="txtQuantity" Text='<%# Bind("Quantity") %>'></asp:TextBox>
    </EditItemTemplate>
    <UpdateBindings>
    <wijmo:C1GridViewUpdateBinding ControlProperty="txtQuantity.Text" UpdateField="Quantity" />
    </UpdateBindings>
    </wijmo:C1TemplateField>


     protected void C1GridView1_RowDataBound(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewRowEventArgs e)
    {
    Label lbl1 = (Label)e.Row.FindControl("lblQuantity");
    if (lbl1 != null && lbl1.Text != "")
    {
    lbl1.Text = String.Format("{0:n0}", Convert.ToInt32(lbl1.Text)).ToString();
    }
    }


    Regards
    Abdias
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels