Click here to Skip to main content
15,904,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to set the Grid view column as wrap text, i mean the data is without any spaces is there in gridview column like



+RESP:GTRTL,030101,868487000014282,,1,,4,1.1,-78.786353,35.785477,20110416161814,,310,260,8FDB,2731,,001874C53A71,2,,20110418032714,0014$


because of this the page design is disturbing... so plese guide me that what should I do in the gridview....
Posted
Updated 22-Nov-11 22:28pm
v2
Comments
Vikas_Shukla_89 23-Nov-11 4:38am    
try this way..ur

<asp:BoundField DataField="your datafield name" HeaderText="ur headertext" HtmlEncode="false" HeaderStyle-Wrap="false" ItemStyle-Wrap="false">


hope this help u
Prince Antony G 7-Feb-12 3:42am    
try in repeater control..

Use word-wrap[^] property in CSS
 
Share this answer
 
try this to implement the below method inside of ur search click event...here i have given the sample search with different fields one is ddl and textbox, keep ur textbox id's and try..


C#
public void SearchStudentInfo()
    {
        try
        {
            lblError.Text = string.Empty;
            if (txtSearch.Text.Trim() != string.Empty || ddlUserType.SelectedIndex != 0 || ddlStatus.SelectedValue != "-1")
            {
                ViewState["SearchText"] = txtSearch.Text.Trim();
                studentCollection = SerachData((MyGenericCollection<StudentBO>)ViewState["StudentCollection"], Convert.ToString(ViewState["SearchText"]));
                if (studentCollection.Count > 0)
                {
                    ViewState["SearchCollection"] = studentCollection;
                    ViewState["SearchText"] = txtSearch.Text.Trim();
                    BindGridView(studentCollection, true);
                }
                else
                {
                    BindGridView(null, true);
                }
            }
            else
            {
                BindGridView((MyGenericCollection<StudentBO>)ViewState["StudentCollection"], false);
            }
        }
        catch (Exception ex)
        {
            ExpLogBL.CreateExceptionLog(ex, "Sohan", "Officer/UserInfo.aspx");
            Response.Redirect("../Common/Errorpage.aspx");
        }
    }

--

 private MyGenericCollection<StudentBO> SerachData(MyGenericCollection<StudentBO> studentCollection, string NameOrId)
    {
        try
        {
            string strName = string.Empty;
            MyGenericCollection<StudentBO> searchCollection = new MyGenericCollection<StudentBO>();
            foreach (StudentBO objStudentBO in studentCollection)
            {
                bool bUserType = true;
                bool bUserStatus = true;
                strName = objStudentBO.FirstName + " " + objStudentBO.LastName;

                if (ddlUserType.SelectedIndex != 0)
                {
                    //byte uType = Convert.ToByte(ddlUserType.SelectedValue);
                    //if (uType > 0 && (objStudentBO.UserType != (Constants.UserType)uType || objStudentBO.IsSpecial == true)) { bUserType = false; }
                    //else if (uType == 0 && objStudentBO.IsSpecial == false) { bUserType = false; }
                    if (objStudentBO.UserType != (Constants.UserType)Convert.ToByte(ddlUserType.SelectedValue)) { bUserType = false; }
                }
                if (ddlStatus.SelectedIndex != 0)
                {
                    byte Status = Convert.ToByte(ddlStatus.SelectedValue);
                    if (Status >= 0 && (objStudentBO.Status != Convert.ToBoolean(Status))) { bUserStatus = false; }
                }
                if (bUserStatus == true && bUserType == true && strName.IndexOf(NameOrId, 0, StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    searchCollection.Add(objStudentBO);
                }
            }
            return searchCollection;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
 
Share this answer
 
v2
Comments
Anuja Pawar Indore 7-Feb-12 3:23am    
Added pre tag

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