Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one grid in this multiple column i.e.country,city,song name and download...
but this grid is left side of page nd i want to display error message in right side of gridview but my grid width is too much big bcz of song name (column )is big so that msg display in below of grid so how i can manage width of that column???or how to reduce that column width???
please help me....
thanks in advance
Posted

Hi,
Try this

protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView1.Columns[2].ItemStyle.Width =300;
GridView1.Columns[2].ItemStyle.Wrap = false;
}
}

(or)

for button click

for (int i = 0; i < GridView1.Columns.Count; i++)
{
GridView1.Columns[i].ItemStyle.Width = 300;
GridView1.Columns[i].ItemStyle.Wrap = false;
}
 
Share this answer
 
XML
In the Source on the page you can go in BoundField column and change its size right there.
example:
<asp:BoundField HeaderText="City"; DataField="VARCHARCITY"; ItemStyle-HorizontalAlign="Center" ItemStyle-Width="250px"/>
 
Share this answer
 
v2

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