PC Review


Reply
Thread Tools Rate Thread

Datagridview edit row with checkbox

 
 
rgparkins
Guest
Posts: n/a
 
      5th Oct 2007
HI I am struggling with this one and its got to be a simple solution.
I have 3 columns in a datagridview the 4th being the edit/delete
buttons for that row, when I click the edit button I have the
following:

column 1 is a textbox
column 2 is a checkbox
column 3 is a dropdownlist

When I do an update the only column that is updated is the textbox,
the other 2 dont pass the new value I have selected to the update
method on the objectdatasource. Could anyone throw me a lifeline, I am
using .NET 2.0

I have checked at the db and yes the only one that is updated is the
textbox so its not a binding issue after the update.

Many thanks

Richard

 
Reply With Quote
 
 
 
 
Kbalz
Guest
Posts: n/a
 
      5th Oct 2007
On Oct 5, 6:42 am, rgparkins <rgpark...@hotmail.com> wrote:
> HI I am struggling with this one and its got to be a simple solution.
> I have 3 columns in a datagridview the 4th being the edit/delete
> buttons for that row, when I click the edit button I have the
> following:
>
> column 1 is a textbox
> column 2 is a checkbox
> column 3 is a dropdownlist
>
> When I do an update the only column that is updated is the textbox,
> the other 2 dont pass the new value I have selected to the update
> method on the objectdatasource. Could anyone throw me a lifeline, I am
> using .NET 2.0
>
> I have checked at the db and yes the only one that is updated is the
> textbox so its not a binding issue after the update.
>
> Many thanks
>
> Richard


Can you post all of the gridview's related code, and datasource's code
(like updatestatements).

 
Reply With Quote
 
rgparkins
Guest
Posts: n/a
 
      5th Oct 2007
Hi Kbatz

As requested, many thanks, the objectdatasource calls the background
routine here:

/// <summary>
/// UPdate product detail
/// </summary>
/// <returns></returns>
public static void UpdateProduct(long PId, string PCostString,
string PDescription, decimal PGross, bool PSpecial, int PStatus, bool
PBillable, string PSupplimentary1) ;


Many thanks

Rich

<asp:GridView ID="GridViewDetail" DataSourceID="ObjectDataSource1"
runat="server" AutoGenerateColumns="False"
DataKeyNames="PId,PSpecial,PBillable,PStatus" PageSize="100"
OnRowDataBound="GridViewDetail_RowDataBound" ShowFooter="True"
OnRowCommand="GridViewDetail_RowCommand"
OnRowUpdating="GridViewDetail_RowUpdating"
CssClass="subcostsfullspan">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button Text="Edit" CommandName="Edit"
CausesValidation="false" runat="server" ID="btEdit" />&nbsp;
<asp:Button Text="Delete" CommandName="Delete"
CausesValidation="false" runat="server" ID="btDelete" />
</ItemTemplate>
<EditItemTemplate>
<asp:Button Text="Update" CommandName="Update"
CausesValidation="false" runat="server" ID="btUpdate" />&nbsp;
<asp:Button Text="Cancel" CommandName="Cancel"
CausesValidation="false" runat="server" ID="btCancel" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button Text="Insert" CommandName="Insert"
CausesValidation="true" runat="server" ID="btInsert" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBoxGridDescription"
runat="server" Text='<%# Bind("PDescription") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelDescription" runat="server"
Text='<%# Bind("PDescription") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBoxGridDescriptionInsert"
runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cost (&#163">
<EditItemTemplate>
<asp:TextBox ID="TextBoxGridGross" runat="server"
Text='<%# Bind("PGross") %>' CssClass="subcostsfullspantxtbox"></
asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelGross" runat="server" Text='<
%# Bind("PGross") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBoxGridGrossInsert"
runat="server" CssClass="subcostsfullspantxtbox"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cost string">
<EditItemTemplate>
<asp:TextBox ID="TextBoxGridCostString"
runat="server" Text='<%# Bind("PCostString") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelCostString" runat="server"
Text='<%# Bind("PCostString") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBoxGridCostStringInsert"
runat="server" CssClass="subcostsfullspantxtbox"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Special">
<EditItemTemplate>
<asp:CheckBox ID="CheckBoxGridSpecial"
runat="server" Checked='<%# Bind("PSpecial")%>'></asp:CheckBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelSpecial" runat="server" Text='<
%# Bind("PSpecial") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="CheckBoxGridSpecialInsert"
runat="server"></asp:CheckBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Billable">
<EditItemTemplate>
<asp:CheckBox ID="CheckBoxGridBillable"
runat="server" Checked='<%# Bind("PBillable")%>'></asp:CheckBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelBillable" runat="server"
Text='<%# Bind("PBillable") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="CheckBoxGridBillableInsert"
runat="server"></asp:CheckBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<EditItemTemplate>
<aspropDownList ID="DropDownListGridStatus"
runat="server">
<asp:ListItem Value="1" Text="For Sale"></
asp:ListItem>
<asp:ListItem Value="2" Text="On Hold"></
asp:ListItem>
<asp:ListItem Value="3" Text="Sold"></
asp:ListItem>
</aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelStatus" runat="server" Text='<
%# Bind("PStatus") %>'></asp:Label>
</ItemTemplate>

<FooterTemplate>
<aspropDownList
ID="DropDownListGridStatusInsert" runat="server">
<asp:ListItem Value="1" Text="For Sale"></
asp:ListItem>
<asp:ListItem Value="2" Text="On Hold"></
asp:ListItem>
<asp:ListItem Value="3" Text="Sold"></
asp:ListItem>
</aspropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="# Rooms" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBoxGridSupplimentary1"
runat="server" Text='<%# Bind("PSupplimentary1") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelTextBoxGridSupplimentary1"
runat="server" Text='<%# Bind("PSupplimentary1") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TextBoxGridSupplimentary1Insert"
runat="server" CssClass="subcostsfullspantxtbox"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

</Columns>
<EmptyDataTemplate>
<table border="0" width="100%" cellspacing="0"
cellpadding="0">
<tr>
<td class="heading">Description:</td>
<td><asp:TextBox
ID="TextBoxGridDescriptionInsertEmpty" runat="server"
CssClass="inpvariants"></asp:TextBox></td>
</tr>
<tr>
<td class="heading">Gross:</td>
<td><asp:TextBox ID="TextBoxGridGrossInsertEmpty"
runat="server" CssClass="inpvariants"></asp:TextBox></td>
</tr>
<tr>
<td class="heading">CostString:</td>
<td><asp:TextBox ID="TextBoxGridCostStringInsertEmpty"
runat="server" CssClass="inpvariants"></asp:TextBox></td>
</tr>
<tr>
<td class="heading">Special:</td>
<td><asp:CheckBox ID="CheckBoxGridSpecialInsertEmpty"
runat="server"></asp:CheckBox></td>
</tr>
<tr>
<td class="heading">Billable:</td>
<td><asp:CheckBox ID="CheckBoxGridBillableInsertEmpty"
runat="server"></asp:CheckBox></td>
</tr>
<tr>
<td class="heading">Status:</td>
<td><aspropDownList
ID="DropDownListGridStatusInsertEmpty" runat="server"
CssClass="inpvariants">
<asp:ListItem Value="1" Text="For Sale"></
asp:ListItem>
<asp:ListItem Value="2" Text="On Hold"></
asp:ListItem>
<asp:ListItem Value="3" Text="Sold"></
asp:ListItem>
</aspropDownList></td>
</tr>
<tr>
<td class="heading"><asp:Label
ID="LabelSupplimentary1" runat="server" Text="Supplimentary"></
asp:Label>:</td>
<td><asp:TextBox ID="TextBoxGridSupplimentary1Empty"
runat="server" CssClass="inpvariants"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" align="right"><asp:Button ID="btSend"
Text="Insert" runat="server" CommandName="EmptyInsert"
UseSubmitBehavior="False" /></td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
&nbsp;
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetProductsByCategory"

TypeName="SurbitonPlaza.LifeStyleSystem.BusinessLayer.Search.ProductManager"
UpdateMethod="UpdateProduct" DeleteMethod="DeleteProduct"
OnDeleting="ObjectDataSource1_Deleting"
OnUpdating="ObjectDataSource1_Updating">
<UpdateParameters>
<asp:Parameter Name="PId" Type="Int64" />
<asp:Parameter Name="PCostString" Type="String" />
<asp:Parameter Name="PDescription" Type="String" />
<asp:Parameter Name="PGross" Type="Decimal" />
<asp:Parameter Name="PSpecial" Type="Boolean" />
<asp:Parameter Name="PStatus" Type="Int32" />
<asp:Parameter Name="PBillable" Type="Boolean" />
<asp:Parameter Name="PSupplimentary1" Type="String" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="PId" Type="Int64" />
</DeleteParameters>
</asp:ObjectDataSource>



 
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
DataGridView checkbox. Mr. X. Microsoft VB .NET 4 25th Jun 2010 08:01 AM
Datagridview checkbox Cdude Microsoft C# .NET 3 30th Apr 2010 07:16 PM
DataGridView Checkbox Carolina Microsoft Dot NET Framework Forms 3 17th Sep 2007 08:14 PM
datagridview checkbox mrstrong Microsoft Dot NET 0 7th Sep 2007 04:51 AM
Get value of a checkbox in a datagridview =?Utf-8?B?RGF2ZQ==?= Microsoft C# .NET 0 16th Oct 2006 10:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:47 AM.