Dynamically added Checkbox in Gridview

G

Guest

I am dynamically adding a checkbox in a gridview and I find there are several
things that I cannot figure out how to address.

1. The width of the checkbox column is very wide. I've tried adding
properties and Item Style to the column but it has no effect. Is there
someway to size this column to be smaller? I removed the CssClass property
and it had no effect on the size as well.

2. The gridview is sortable using javascript. Is there any way to keep
checkboxes selected after the sort?

<asp:GridView ID="GridViewResults" runat="server"
AutoGenerateColumns="False"
CssClass="sortable" >
<Columns>
<asp:TemplateField HeaderText="Select" >
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<ItemStyle width="20px" />
</asp:TemplateField>
<asp:HyperLinkField DataNavigateUrlFields="QuoteID"
DataNavigateUrlFormatString="SetupSummary.aspx?QuoteID={0}"
DataTextField="UserFriendlyQuoteID" HeaderText="Quote ID"
NavigateUrl="~/SetupSummary.aspx"
SortExpression="UserFriendlyQuoteID" />
<asp:BoundField DataField="QuoteStatusDescription"
HeaderText="Status" />
<asp:BoundField DataField="AcceptedDate" HeaderText="Accept
Date" />
<asp:BoundField DataField="Notes" HeaderText="Notes" />
</Columns>
</asp:GridView>

Any thoughts would be appreciated.
Bill
 
M

MatsL

If the checkbox is wider than 20px then the column will be as wide as
the checkbox control. Try setting CssClass of the column and set these
properties for the class

..CheckBoxColumnClass
{
width: 20px;
overflow: hidden; /* <- that will hide anything that is wider than 20px
inside the cell */
}

Don't really know much about javascript sorting gridviews, so I can't
help you there.

//Mats
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top