473,405 Members | 2,300 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,405 software developers and data experts.

Checkbox Column Not Appearing

Ben
Hi,

I'm designing a c# page and trying to add a checkbox column to a
GridView, I've added a Template Row (as described at:
http://aspnet.4guysfromrolla.com/articles/052406-1.aspx) and in the
Edit Templates dragged a Checkbox into the Item Template.

The new column shows up, but it's empty...no checkbox appears. Any
ideas? here's the source if it helps:
<ContentTemplate>
<asp:GridView ID="gridIssues" runat="server"
AllowSorting="True" CellPadding="4"
ForeColor="#333333" GridLines="None"
OnSorting="gridIssues_Sorting" Style="font-size: 10pt;
font-family: arial"
OnDataBinding="gridIssues_DataBinding"
OnDataBound="gridIssues_DataBound"
OnRowDataBound="gridIssues_RowDataBound" DataKeyNames="MonitorID">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" /
>
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-
Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White"
ForeColor="#284775" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1"
runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
btw, I'm not setting a Data Source in the designer... in my code, I
load a DataView into memory and then bind it to the GridView... not
sure if that changes something...

Thanks so much!!
Dec 31 '07 #1
1 2373
Ben
On Dec 31 2007, 11:07*am, Ben <benm5...@gmail.comwrote:
Hi,

I'm designing a c# page and trying to add a checkbox column to a
GridView, I've added a Template Row (as described at:http://aspnet.4guysfromrolla.com/articles/052406-1.aspx) and in the
Edit Templates dragged a Checkbox into the Item Template.

The new column shows up, but it's empty...no checkbox appears. *Any
ideas? *here's the source if it helps:

<ContentTemplate>
* * * * * * * * <asp:GridView ID="gridIssues" runat="server"
AllowSorting="True" CellPadding="4"
* * * * * * * * * * ForeColor="#333333" GridLines="None"
OnSorting="gridIssues_Sorting" Style="font-size: 10pt;
* * * * * * * * * * font-family: arial"
OnDataBinding="gridIssues_DataBinding"
OnDataBound="gridIssues_DataBound"
OnRowDataBound="gridIssues_RowDataBound" DataKeyNames="MonitorID">
* * * * * * * * * * <FooterStyle BackColor="#5D7B9D"Font-Bold="True"
ForeColor="White" />
* * * * * * * * * * <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /

* * * * * * * * * * <EditRowStyle BackColor="#999999" />
* * * * * * * * * * <SelectedRowStyle BackColor="#E2DED6" Font-
Bold="True" ForeColor="#333333" />
* * * * * * * * * * <PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
* * * * * * * * * * <HeaderStyle BackColor="#5D7B9D"Font-Bold="True"
ForeColor="White" />
* * * * * * * * * * <AlternatingRowStyle BackColor="White"
ForeColor="#284775" />
* * * * * * * * * * <Columns>
* * * * * * * * * * * * <asp:TemplateField>
* * * * * * * * * * * * * * <ItemTemplate>
* * * * * * * * * * * * * * * * <asp:CheckBox ID="CheckBox1"
runat="server" />
* * * * * * * * * * * * * * </ItemTemplate>
* * * * * * * * * * * * </asp:TemplateField>
* * * * * * * * * * </Columns>
* * * * * * * * </asp:GridView>
* * * * * * </ContentTemplate>

btw, I'm not setting a Data Source in the designer... in my code, I
load a DataView into memory and then bind it to the GridView... not
sure if that changes something...

Thanks so much!!
I found out my issue, in case someone else runs into it... I was
replacing each cell's text with a 'decoded' html... since some of my
columns had hypertext in there and I wanted it to be parsed -- I guess
it was screwing up the TemplateField...not sure why...maybe there's a
better way? ...for now I skipped the cell that has the checkbox and it
solved the issue:
protected void gridIssues_RowDataBound(object sender,
GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 1; i < e.Row.Cells.Count; i++) //<----
changed i to a 1 instead of 0, so it skips the first checkbox column
{
e.Row.Cells[i].Text =
Server.HtmlDecode(e.Row.Cells[i].Text);
}
}
}
Jan 2 '08 #2

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

Similar topics

3
by: Randy | last post by:
Hello, I'm creating a table on the fly that is used by a datagrid. I'm also creating a tableStyle that is used for the datagrid to make it look like I want. I'm using the DataGridBoolColumn to...
1
by: Paul | last post by:
HI I have a asp page which dynamically creates a table with 28 rows, 3 columns. Column 1 contains a label, column 2 contains a graphic, column 3 needs to contain a checkbox. I have no problems...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
1
by: Machi | last post by:
Let say i select rows of records with 4 columns from Database and want to display the data in DataGrid (ASP.NEt Server Control) with one column which must be displayed in CheckBox layout. For the...
10
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox...
17
by: Mike Fellows | last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid i basically have a datagrid that im populating from a dataset Me.DataGrid1.DataSource = ds.Tables(0) the datagrid then has 5...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
4
by: Mike Haberfellner | last post by:
....hi everyone, ....i posted this allready, but my newsreader doesn't display it to me - so i'm sorry if it's posted twice... hi again, sorry for not clearly writing what i really need :) ...
1
by: janetb | last post by:
I have a gridview with an update capabilities - a textbox column (roomName), a dropdownlist(orgID), a dropdownlist(roomTypeID),a checkbox column (dialOut), a checkbox column (dialIn). When I try to...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.