Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Datagridview edit row with checkbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rgparkins - 05 Oct 2007 11:42 GMT
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
Kbalz - 05 Oct 2007 12:55 GMT
> 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
[quoted text clipped - 16 lines]
>
> Richard

Can you post all of the gridview's related code, and datasource's code
(like updatestatements).
rgparkins - 05 Oct 2007 13:33 GMT
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>
                   <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>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.