Datagridview edit row with checkbox

R

rgparkins

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
 
K

Kbalz

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).
 
R

rgparkins

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 (£)">
<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>
<asp:DropDownList 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>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelStatus" runat="server" Text='<
%# Bind("PStatus") %>'></asp:Label>
</ItemTemplate>

<FooterTemplate>
<asp:DropDownList
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>
</asp:DropDownList>
</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><asp:DropDownList
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>
</asp:DropDownList></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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top