Click here to Skip to main content
15,900,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview that is populated from a sql statement. The sql statement contains a reference to a dropdown list. Basically when something is selected from the dropdown the gridview is populated. At the moment when this happens and a generated field from the table is really long the gridview is displayed with the column this field relates to being one single long string that blows the gridview off the browser window. I would like to know therefore how to wordwrap the aforementioned column.

Please advise if your able or perhaps suggest a better method to display the data.

Thanks in advance
Posted

Well putting your gridview in div with a style="overflow-x:scroll;" or asp.net panel with ScrollBars="Horizontal" property might help you to overcome off browser window display.
 
Share this answer
 
Comments
Andrew Chambers 29-Nov-11 0:07am    
not quite the effect I am looking for. but thanks.
Wonde Tadesse 6-Dec-11 11:23am    
Thanks
You can adjust the size of your gridviews columns using edit item template and as per your requirement you can use the modified size and also you can apply style to your grid view....


or please be more specific in using language to demon strait your question.
 
Share this answer
 
Comments
Andrew Chambers 29-Nov-11 0:07am    
As the gridview is generated dynamically from an sql statement in the code behind page item template is never generated and therefore I am unable to edit it.

Code relating to the gridview is below:
<asp:GridView ID="GridView1" runat="server" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
ForeColor="Black" GridLines="Vertical" >
<alternatingrowstyle backcolor="#CCCCCC">
<footerstyle backcolor="#CCCCCC">
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<sortedascendingcellstyle backcolor="#F1F1F1">
<sortedascendingheaderstyle backcolor="#808080">
<sorteddescendingcellstyle backcolor="#CAC9C9">
<sorteddescendingheaderstyle backcolor="#383838">

code behind is:

protected void dropDownRole_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
sql = "SELECT FORMAT(Change_Date,'DD/MM/YYYY') As Change_Date , FORMAT(Change_Time,'HH:MM:SS') As Change_Time, Ticket, Customer, Server_Name, Role, Task, Change, Comment, Engineer FROM change_control WHERE Role ='" + dropDownRole.SelectedValue + "'";
oleDbconn.Open();
oleDbcomm = new OleDbCommand(sql, oleDbconn);
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(oleDbcomm);
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
catch (Exception ex)
{
ex.Message.ToString();
}
finally
{
oleDbconn.Close();
}
}

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