Showing posts with label GridView. Show all posts
Showing posts with label GridView. Show all posts

Thursday, April 1, 2010

Gridview nowrap

What do you do when you have
AllowPaging="False" AllowSorting="False" AutoGenerateColumns="True" Width="800px" ShowHeader="true"

And it wraps all your data?

you add:

OnRowDataBound="GridView_RowDataBound"

and then:

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Attributes.Add("style", "white-space: nowrap;");
}
}

Wednesday, April 16, 2008

GridView Id column

If I make a "BoundColumn" for the Id, with visible - false, I can't get the Id ...

This one works:
(rowdatabound)




e.Row.Cells["mycolumn"].Style.Add("display", "none");




this way the Id is still there, you just cannot see it...

Gridview rowcount from Js

I needed to get some rowcont in a Js variable, to have a google-like "select all" (all from all pages) button, that i didn't want to show up if there is only one page in my gridview.

Radu helped me out with this idea:
(I am using this on rowDataBound, because I didn't want to use an other event, I already had this one ...)




ScriptManager.RegisterClientScriptBlock(grvAgentCommissionFeePercentage, this.GetType(), "ScriptIDAndTicksForRefreshnumber" + DateTime.Now.Ticks.ToString(), "multiplePages = " + grvAgentCommissionFeePercentage.PageCount.ToString() + ";", true);




if you need the whole nine yards, just comment ... i'll get back to you