Click here to Skip to main content
15,909,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have worlds like this kkkkkkkkkkkkkkkkkkmmmmmmmmmmmmmmkkkkkkkkkkkkkkkkknnnnnnnnxxxsssssssxxxxx.when it is show in gridview then show in one line.the design of grid view is not proper correctly.i want to space after 50 charactor
Posted

C#
String mytext = "kkkkkkkkkkkkkkkkkkmmmmmmmmmmmmmmkkkkkkkkkkkkkkkkknnnnnnnnxxxsssssssxxxxx";
                    if (mytext.Length > 50)
                    {
                        String temptext = "";
                        temptext = mytext.Substring(0, 50) + " " + mytext.Substring(51);
                    }
 
Share this answer
 
I doubt you really want space,
I think you want to fix width of that coloumn.
C#
<asp:boundfield headertext="Email" datafield="Email" xmlns:asp="#unknown">ItemStyle-Width="75" />
</asp:boundfield>

or if you really want space then
onRowBound event of gridview
C#
protected void rowbound(object sender, GridViewRowEventArgs e)
    {
        //int index = Convert.ToInt32(e.Row);
        GridViewRow row = e.Row;

        string s = row.Cells[5].Text;
        s = s.PadLeft(50, ' '); 
        row.Cells[5].Text=s;
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900