473,888 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically added Checkbox in Gridview

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="GridViewRes ults" runat="server"
AutoGenerateCol umns="False"
CssClass="sorta ble" >
<Columns>
<asp:TemplateFi eld HeaderText="Sel ect" >
<ItemTemplate >
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<ItemStyle width="20px" />
</asp:TemplateFie ld>
<asp:HyperLinkF ield DataNavigateUrl Fields="QuoteID "
DataNavigateUrl FormatString="S etupSummary.asp x?QuoteID={0}"
DataTextField=" UserFriendlyQuo teID" HeaderText="Quo te ID"
NavigateUrl="~/SetupSummary.as px"
SortExpression= "UserFriendlyQu oteID" />
<asp:BoundFie ld DataField="Quot eStatusDescript ion"
HeaderText="Sta tus" />
<asp:BoundFie ld DataField="Acce ptedDate" HeaderText="Acc ept
Date" />
<asp:BoundFie ld DataField="Note s" HeaderText="Not es" />
</Columns>
</asp:GridView>

Any thoughts would be appreciated.
Bill
Aug 1 '06 #1
1 2897
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

..CheckBoxColum nClass
{
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

Bill44077 wrote:
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="GridViewRes ults" runat="server"
AutoGenerateCol umns="False"
CssClass="sorta ble" >
<Columns>
<asp:TemplateFi eld HeaderText="Sel ect" >
<ItemTemplate >
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<ItemStyle width="20px" />
</asp:TemplateFie ld>
<asp:HyperLinkF ield DataNavigateUrl Fields="QuoteID "
DataNavigateUrl FormatString="S etupSummary.asp x?QuoteID={0}"
DataTextField=" UserFriendlyQuo teID" HeaderText="Quo te ID"
NavigateUrl="~/SetupSummary.as px"
SortExpression= "UserFriendlyQu oteID" />
<asp:BoundFie ld DataField="Quot eStatusDescript ion"
HeaderText="Sta tus" />
<asp:BoundFie ld DataField="Acce ptedDate" HeaderText="Acc ept
Date" />
<asp:BoundFie ld DataField="Note s" HeaderText="Not es" />
</Columns>
</asp:GridView>

Any thoughts would be appreciated.
Bill
Aug 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2883
by: stellstarin | last post by:
I have a html where fields are created and added dynamically on the client side. I use the AppendChild() call to create fields dynamically. On submit i try to get the value for all the elements in the form, including those that are added dynamically. I use document.getElementsByName('Field Name')to achieve the same.
4
5058
by: sydney.luu | last post by:
Hello, I would greatly appreciate if someone can show me how to dynamically build a Repeater with unknown number of columns at design time. I have looked various threads in this newsgroup, websites, MSDN and was not able to find something that would help me understand and code. I might not be searching for the right words or phrases. So if you know how to do this or know of links or websites that have information about this, please...
2
2462
by: Pete Moss | last post by:
During a postback event, I am having trouble retrieving the state of a CheckBox Control that I am dynamically adding to a DataGrid Control using ASP.NET 1.1. I have no trouble adding the TemplateColumn dynamically. I persist a DataSet in my Session object and I bind the CheckBox to the DataSet. So far so good. The CheckBoxes show up and the user interacts with them (checks a few, unchecks a few). The problem is that during a postback...
3
2891
by: keithb | last post by:
My code dynamically adds template fields to a GridView control. Everything seems to work OK, except when updating, because I haven't found a way to reference the dynamically added textboxes. FindControl doesn't work, and the textboxes cannot be accessed using grid.Rows.Cells.Control. Can someone help? Thanks, Keith
0
1893
by: yeltsin27 | last post by:
I need some advice on handling dynamically added controls in a GridView. My app takes an uploaded CSV file containing addresses, converts it to a DataTable, databinds the DataTable to a GridView, accepts information via dropdowns embedded in the first row of the GridView about which incoming fields should go to which database fields, and writes the data to the database. The incoming data has an arbitrary number of columns so I create...
2
4673
by: somaskarthic | last post by:
Hi In my php code , i dynamically created table rows on button click event. Each row contain 3 selectboxes, 7 checkboxes . On each click of these elements i need to submit the form and save the data to database. After each submit , i need to display the previous added details (with some checkboxes checked and some others unchecked ..) and one new row for next updation. Here i need to collect all values submitted in the php page. There i...
9
7943
by: Chris | last post by:
I am dynamically adding a user control to each row in a gridview. The reason I am doing it dynamically is the user control is different depending on certain data in the gridview. The gridview contains a placeholder and I add the control to it, the user control is a formview bound to an object datsource. This works great until I post back the page and the user control disappears. What am I doing wrong? Regards, Chris. Protected Sub...
3
9015
by: =?Utf-8?B?Um9iZXJ0IFNtaXRo?= | last post by:
Hi, I have a GridView with a checkbox column in it called FromInsight, however this is not bound to the dataset, its value is based on another column from the dataset called sourceid For each row FromInsight = true if (SourceId 0). I try to loop around the gridview and add the value of the checkbox but the column seems to have no checked value, please can you help with this. Thanx in advance Robert
4
11030
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like to iterate thru the gridview's rows, examine the databound controls, then perform a database action. for some reason, i can't find the controls. i have a two templates: one that uses a label the other uses a textbox to display data. when the...
0
9961
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11185
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7990
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5824
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4247
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.