Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Checkbox Column Not Appearing

Reply
Thread Tools

Checkbox Column Not Appearing

 
 
Ben
Guest
Posts: n/a
 
      12-31-2007
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!!
 
Reply With Quote
 
 
 
 
Ben
Guest
Posts: n/a
 
      01-02-2008
On Dec 31 2007, 11:07*am, Ben <(E-Mail Removed)> wrote:
> 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);
}
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Links in Outlook Express not working,page not appearing Thaqalain Computer Support 7 09-30-2005 12:48 PM
CheckBoxList values not appearing and State not maintained when ne jmhmaine ASP .Net Web Controls 0 01-20-2005 04:25 PM
Activa or not activate a button column depending if another data column has data or not carlos perez ASP .Net 0 06-08-2004 02:16 PM
Convert an MS Access Yes/No column to a checkbox column in C# datagrid Gregory Rampton ASP .Net Datagrid Control 0 08-06-2003 04:09 PM
TreeView: Checkbox data not appearing in Request / POST data Kris Oye ASP .Net Web Controls 1 07-30-2003 02:26 PM



Advertisments