PC Review


Reply
Thread Tools Rate Thread

datagrid and checkbox

 
 
mamun
Guest
Posts: n/a
 
      14th Feb 2007
Hi All,

I have the following situation.

In the aspx page, I have a datagrid and getting values from the
database.

I am displaying checkbox in each row of the grid. At the top of the
grid I have an "Update" button which will be used to update the
contents based on Bore_Id field. This field in the database is Number
type.

Here is the snippet of my code in page.aspx. The name (or id) of the
datagrid is BoreHolesResult. I will be updating based on the selected
checkbox and this checkbox should relate to the field Bore_Id.


<asp:TemplateColumn HeaderText="Type" >
<ItemTemplate>
<asp:TextBox ID="txtType" Runat="server" text='<
%#DataBinder.Eval(Container.DataItem, "BORE_TYPE") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn>
<HeaderTemplate>
<asp:Button ID="btnUpdateBoreId" Runat="server" Text="Update"
Onclick="UpdateBoreID"></asp:Button>
</HeaderTemplate>
<ItemTemplate>

<asp:CheckBox ID='chkid' enabled='<
%#((System.Data.DataRowView)Container.DataItem)["BORE_ID"].ToString()
%>'
Runat="server">
</asp:CheckBox>

</ItemTemplate>
</asp:TemplateColumn>


In the code file (page.aspx.cs),

I have the following:

public void UpdateBoreID(object sender, EventArgs e) //, string
BoreID
{

foreach (DataGridItem item in
BoreHolesResult.Items)
{
string BoreType;
CheckBox cb =
(CheckBox)BoreHolesResult.Items[8].FindControl("chkid");
if (cb.Checked == true)
{
BoreType =
((TextBox)item.FindControl("txtType")).Text;
Response.Write(BoreType);
}
}
}


I am having problem and the build is failed saying cannot convert
string to bool.

I have been struggling with this for the last two days. I will highly
appreciate if you could help me.

Thanks a ton in advance.

best regards,
mamun

 
Reply With Quote
 
 
 
 
=?Utf-8?B?WE9S?=
Guest
Posts: n/a
 
      15th Feb 2007
try this

<asp:CheckBox ID='chkid' enabled='
%#Bool.parse(((System.Data.DataRowView)Container.DataItem)["BORE_ID"].ToString())
%>'
Runat="server">
</asp:CheckBox>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
DataGrid and embeded Checkbox..How to find if checkbox clicked =?Utf-8?B?RG90TmV0RGV2?= Microsoft ASP .NET 1 6th Oct 2006 05:11 PM
How add Checkbox to datagrid Harsh Trivedi Microsoft Dot NET Compact Framework 0 18th Jul 2005 06:17 AM
DataGrid: Add Checkbox Frank Esser Microsoft ASP .NET 1 11th Mar 2005 02:31 PM
Master-Detail Datagrid -checkbox (once tick the checkbox, all the child checkbox is ticked) Agnes Microsoft VB .NET 0 16th Aug 2004 11:23 AM
Added CheckBox to a DataGrid Doesn't work with DataGrid.Enabled=False Amar Microsoft ASP .NET 0 6th Apr 2004 11:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:13 PM.