473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

true? binding arraylist to a gridview seems to be read only

BeemerBiker
I converted an arraylist to a dataset and bound the dataset to a gridview but I cannot change the value of the checkbox in the gridview. I identified the DataKeyNames and made sure that ReadOnly was false. For the CheckBoxField I bound it to prjused and the label template was bound to prjname. I need to be able to change only the prjused field.

the following gridview aspx
Expand|Select|Wrap|Line Numbers
  1.  <Columns>
  2.                                                 <asp:CheckBoxField HeaderText="Select" 
  3.                                                 DataField="prjused">
  4.                                                 <ControlStyle Width="50%" />
  5.                                                 <ItemStyle Width="50%" />
  6.                                                 </asp:CheckBoxField>
  7.                                                 <asp:TemplateField HeaderText="BOINC Project">
  8.                                                     <ItemTemplate>
  9.                                                         <asp:Label ID="lbProject" runat="server" 
  10.                                                         Text='<%# Bind("prjname") %>'></asp:Label>
  11.                                                     </ItemTemplate>
  12.                                                     <ItemStyle Width="50%" />
  13.                                                 </asp:TemplateField>
  14.                                             </Columns>

the following C# code created and bound the gridview

Expand|Select|Wrap|Line Numbers
  1. private DataSet FormPNdataset()
  2.         {
  3.             DataSet dsTemp = new DataSet();
  4.             DataTable Tables = new DataTable();
  5.             dsTemp.Tables.Add(Tables);
  6.             dsTemp.Tables[0].Columns.Add("prjused", System.Type.GetType("System.Boolean"));
  7.             dsTemp.Tables[0].Columns.Add("prjname",System.Type.GetType("System.String"));
  8.             foreach (string strname in ProjectNames)
  9.             {
  10.                 DataRow dr = dsTemp.Tables[0].NewRow();
  11.                 dr["prjused"] = true;
  12.                 dr["prjname"] = strname;
  13.                 dsTemp.Tables[0].Rows.Add(dr);
  14.             }
  15.             return dsTemp;
  16.         }
  17.  
  18. ---then--
  19. gv.DataSource = FormPNdataset();
  20. gv.DataBind();
  21.  
  22.  
The above works fine, but the checkbox column is grayed out.

Googleing I see where someone suggested using "BindingLIst" and I found this reference: http://msdn.microsoft.com/en-us/library/ms132679.aspx but this seems only for listboxes and not gridviews.

I can always add an unbound column of checkboxes and do my own checkbox state control but I would rather use a two way data set.

maybe there is an asp.net version of the windows forms widget "CheckListBox" ? I am trying to roll my own CheckListBox.

thanks for looking
Sep 24 '09 #1
1 3274
solved - after sleeping on it I tried converting the checkbox bound data field into a template and the checkboxes became read/write.

However, it would be nice if a checkboxlist existed in asp.net
Sep 24 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: sck10 | last post by:
Hello, I have a GridView that is using the following to connect to a SQL Server 2000 stored procedure: <asp:SqlDataSource ID="dsWebDocList" SelectCommand="sp_web_WebDocument"...
4
by: Alan Silver | last post by:
Hello, I'm trying to use an ArrayList to do data binding, but am getting an error I don't understand. I posted this in another thread, but that was all confused with various other problems,...
16
by: Michael C# | last post by:
I'm binding a Combobox to an Arraylist, and I'd like to set the ValueMember and DisplayMember properties of the Combobox. Is this possible, or do I need to bind to a DataTable? Thanks
2
by: maflatoun | last post by:
Hi, I'm wondering if there is a way to bind to datagrid or a gridview the items in an arraylist. These items all have vars such as price, qty..etc? (besides putting in a datagrid or datatable...
8
by: AG | last post by:
ASP.NET 2.0, VS 2005 I have a gridview with paging enabled, bound to an objectdatasource. Both were dropped on to the page and configured via the wizards. Basically working as expected. The...
3
by: kevinwolfe | last post by:
Hi all. I'd like any suggestions on how I can get my data set (not a DataSet) bound to a couple of controls on a form. Let me start by describing what my data looks like. Each entry correlates...
1
by: Mike Collins | last post by:
I've seen how to set up a gridview at design time, but I believe I need to do this and run time and cannot figure it out. I am sending a concatenated list of IDs that is gets bigger each time a...
3
by: pblack9455 | last post by:
I have a simple requirement to bind a small ArrayList of (ItemLine) Objects to a GridView control. The Gridview renders on the page and allows me to click update/edit buttons...however the data...
1
by: nomad | last post by:
Hi, I have a two dimensional arraylist below, which I am trying to bind to a gridview. However, when I try and do this the gridview is being populated with what looks like property values i.e....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.