Forms Data Controls :: Gridview With Dropdownlist Edit / Getting An Error

Jan 6, 2010

I have create a grid view with a dropdownlist for one of the columns. This works fine, but when I click edit and then update I get an error saying it cant update due to null value. I'm sure it because the parameter in the update of SqlDataSource1 is not referring to the value select in the edit item template, but I cant figure out how to do this.

My code is below.

<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$
ConnectionStrings:BlazeBillzConnectionString %>"
SelectCommand="SELECT
[Prod_Sold_ID], [Order_Date], [Billing_Period] FROM [ProductsSoldTable] where Prod_Sold_ID < 130"
DeleteCommand="DELETE
FROM [ProductsSoldTable] WHERE [Prod_Sold_ID] = @Prod_Sold_ID"
InsertCommand="INSERT
INTO [ProductsSoldTable] ([Order_Date], [Billing_Period]) VALUES (@Order_Date, @Billing_Period)"
UpdateCommand="UPDATE
[ProductsSoldTable] SET [Order_Date] = @Order_Date, [Billing_Period] = @Billing_Period WHERE [Prod_Sold_ID] = @Prod_Sold_ID">
<DeleteParameters>
<asp:Parameter
Name="Prod_Sold_ID"
Type="Int32"
/>
</DeleteParameters>
<InsertParameters>
<asp:Parameter
Name="Order_Date"
Type="DateTime"
/>
<asp:Parameter
Name="Billing_Period"
Type="Int32"
/>
</InsertParameters>
<UpdateParameters>
<asp:Parameter
Name="Order_Date"
Type="DateTime"
/>
<asp:Parameter
Name="Billing_Period"
Type="Int32"
/>
<asp:Parameter
Name="Prod_Sold_ID"
Type="Int32"
/>
</UpdateParameters>
</asp:SqlDataSource>
</div>
<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="Prod_Sold_ID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField
DataField="Prod_Sold_ID"
HeaderText="Prod_Sold_ID"
InsertVisible="False"
ReadOnly="True"
SortExpression="Prod_Sold_ID"
/>
<asp:BoundField
DataField="Order_Date"
HeaderText="Order_Date"
SortExpression="Order_Date"
/>
<asp:TemplateField
HeaderText="Billing_Period"
SortExpression="Billing_Period">
<EditItemTemplate>
<asp:DropDownList
ID="DropDownList2"
runat="server"
DataSourceID="SqlDataSource5"
DataTextField="Discription"
DataValueField="Bill_Per_Id"
Height="17px"
Width="134px">
</asp:DropDownList>
<asp:SqlDataSource
ID="SqlDataSource5"
runat="server"
ConnectionString="<%$
ConnectionStrings:BlazeBillzConnectionString %>"
SelectCommand="SELECT
[Bill_Per_Id], [Discription] FROM [Billing_Periods]">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:DropDownList
ID="DropDownList1"
runat="server"
DataSourceID="SqlDataSource2"
DataTextField="Discription"
DataValueField="Bill_Per_Id"
Height="19px"
SelectedValue='<%#
Bind("Billing_Period") %>'
Width="171px">
</asp:DropDownList>
<asp:SqlDataSource
ID="SqlDataSource2"
runat="server"
ConnectionString="<%$
ConnectionStrings:BlazeBillzConnectionString %>"
SelectCommand="SELECT
[Bill_Per_Id], [Discription] FROM [Billing_Periods]">
</asp:SqlDataSource>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField
ShowEditButton="True"
/>
</Columns>
</asp:GridView>

View 1 Replies


Similar Messages:

Forms Data Controls :: Gridview Edit Using Dropdownlist?

Aug 2, 2010

i want to edit gridview a gridview column when the user selects particular value in the dropdownlist of gridview?

View 8 Replies

Forms Data Controls :: Need A Dropdownlist After Hit Edit On Gridview

Jul 20, 2010

I have a grid view on my page and and i have a datasource for it,

i also included properties like edit/delete and all

Whenever i hit edit i want a dropdownlist instead of a text box ,can we do this?

View 4 Replies

Forms Data Controls :: GridView Edit Fails On DropDownList

Jun 30, 2010

I have created a Gridview (using ObjectDataSource) for Edit/Updates. I am getting an error on my DropDownList which is configured with the list items Yes and No only for both text and values.

Most of my data in my SQL table has values of either Yes or No, however there are some records that are BLANK or even NULL sometime.These rows fail in my GridView when attempting to Edit.

I tried going into the DDL Edit List items and adding a Blank with and empty value however each time i try to save the page VWD removes it.

How do i account for reverse lookups of all possible values Yes/No/Blank or Empty/NULL in my DDL?

View 2 Replies

Forms Data Controls :: DropDownList In GridView Edit Mode - Set Default Value

Aug 6, 2010

I have gridview that has month as a column. When the user clicks a row's edit button, that row goes into edit mode. I have created a drop-down list for month in edit mode with the values 1-12. Right now, the drop-down list shows 1. I would like it to show the current value for that row. How do I do this? Here's the code for my gridview:

[Code]....

Here's some applicable code from the code behind:

[Code]....

View 4 Replies

Forms Data Controls :: Disable DropDownList In A Gridview Row When In Edit Mode

May 12, 2010

I have the following code in a GridView...

[Code]....

View 2 Replies

Forms Data Controls :: Gridview's Dropdownlist Control Become A Textbox In Edit Mode

Jun 17, 2010

This is my first post on this forum. I have a Gridview with the following Columns

1. Edit Column
2. User_ID (Read Only)
3. Email (Read Only)
4. Role ( A Dropdownlist with 2 list Items namely "Admin" & "QA Lead")

I have used wizard to populate a "Gridview" and the embedded "Dropdownlist" control in it. This is my reference: [URL] My Problem: The Data populates perfectly in Grid and Dropdownlist. But, when I Press "Edit" button the Dropdownlist goes into edit mode in the form of a "Texbox". (i dont want this) I still want it to be an editable dropdownlist.

View 6 Replies

Forms Data Controls :: Gridview DropdownList Losing Index In Edit Mode

May 15, 2010

I have a dropdown list inside a gridview:

[Code]....

View 12 Replies

Forms Data Controls :: Limiting Items In Dropdownlist For Gridview Edit Mode

Jan 18, 2011

I have a Gridview showing the MemberLastName, MemberFirstName, MemberBirthYear, MemberGender, MemberRelationship.

During Edit mode, I have managed to display a DropDownList for the Relationships.What I am trying to achieve now, is that, based on the Gender of the member I would like to limit the items in the Relationships dropdownlist.

e.g if the Gender is Male, then only display Male Relationships

What is the best way to achieve this scenario?Here is my snippet of code for the event. The code is commented out as it throws an exception.

[Code]....

View 3 Replies

Forms Data Controls :: Dropdownlist In Gridview UpdateParameters Empty Data On Edit

Dec 2, 2010

I have a problem with my dropdownlist on edit he doesn't want to add any of his parameters to the update. I tried controlparameter and normall parameter both didn't work The folowing I have: Dropdownlist with Datasource: I Have a gridview with templatefields: I have the following asp.net code:

[Code]....

I have the following Business Layer where it connects to:

[Code]....

View 2 Replies

Data Controls :: Populating DropDownList In Edit ItemTemplate Of GridView?

Aug 29, 2013

I read your article on ASPSnippets and everything worked great.  I am having one problem and this is preventing me from moving forward.  When I select the edit for a row (I only have two columns), the drop down comes back blank (no records).  I have looked at the code multiple times and can't see where I made a mistake. is it possible to control the width of the drop down list?  I can't tell if the column automatically adjusts because I am not returning any records.

using System;
using System.Collections.Generic;
using System.Linq;

[Code].....

View 1 Replies

Data Controls :: Implement Cascading DropDownList In Edit Row Of GridView

Jun 16, 2015

I have question how can make cascading dropdownlist in gridview edit mode

the first dropdown is for departments and second is for classes

the primary table to be updated is employees table

View 1 Replies

Data Controls :: Populate DropDownList In Edit Item Template Of GridView

Feb 25, 2016

I am trying to bind dropdownlist in Gridview under EditItemTemplate under RowBound event. But it gives me blank rows in the drop down list.Here is my Design 

<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblDescription" runat="server" Text='<%# Bind("Description") %>' Width="400px"></asp:Label></ItemTemplate>

[code]....

I see the dropdown but the dropdown is blank, but there are rows in the database for this column and in the footer row it is working fine.

View 1 Replies

Data Controls :: Dynamically Bind Data In DropDownList In GridView Edit Update Delete

Feb 22, 2013

I created  3 category table. categry1,categry2,categry3. product table.

And then use of gried view add ,edit ,update ,delete  product . in product table.

In gridview retrive data from product table . i select categry from dropdownlist in gridview categry1, categry2, categry3 and save update dropdown list category value dynamically  in product table.  not define value static  in source code. 

When select category 1 change  on selected index change categary 2 or 3.

In my code I used text box to ediit update delete. but here i will use dropdownlist. 

View 1 Replies

Data Controls :: Fire GridView Edit Event On DropDownList SelectedIndex Changed

Dec 16, 2013

I am using a dropdownlist in my application and it has corresponding SelectedIndexChanged() event.I would like to invoke GridViewEdit Event when SelectedIndexChanged event fires from dropdown list.Is it possible to implement this...??

<asp:DropDownList ID="ddlStatus" Visible="true" AutoPostBack="true" OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged" runat="server">
</asp:DropDownList>
protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
{
//Code to fire the GridViewEdit Event to put a row in edit mode
}

View 1 Replies

Data Controls :: Update Database Field Using DropDownList In Edit ItemTemplate Of GridView

Mar 10, 2013

[URL]

but i wanted know,how to update the country of any customer by just choosing it from the dropdownlist and updating it in the databse.

i  wanted to add a common update below that updated the country of customers.

View 1 Replies

Forms Data Controls :: Cascading Dropdown List In A GridView Control In Edit Mode Error

Aug 11, 2010

I'm trying to follow this article on cascading dropdown list in a GridView control in edit mode (except I'm using C#) [URL] I keep getting this error message "ProjectID is neither a DataColumn nor a DataRelation for table DefaultView."

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
{
DataRowView dv = (DataRowView)e.Row.DataItem;
//// Preselect correct value in Projects list
DropDownList listProjects = (DropDownList)e.Row.FindControl("DropDownList1");
listProjects.SelectedValue = dv["ProjectID"].ToString(); // *****************this is where I get the error *********
// Databind list of categories in dependent drop-down list
DropDownList listCategories = (DropDownList)e.Row.FindControl("DropDownList2");
SqlDataSource dsc = (SqlDataSource)e.Row.FindControl("sdsDDL2");
dsc.SelectParameters["ProjectName"].DefaultValue = dv["ProjectName"].ToString();
listCategories.DataBind();
listCategories.SelectedValue =(dv["CategoryID"].ToString());
}
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%&#36; ConnectionStrings:ttuser %>" SelectCommand="SELECT
TE.TimeEntryID,
P.ProjectName,
CAT.CategoryName,
TE.TimeEntryDescription,
TE.TimeEntryDuration,
TE.TimeEntryDate
FROM dbo.aspnet_starterkits_TimeEntry TE inner join
dbo.aspnet_starterkits_ProjectCategories CAT on
TE.CategoryID=CAT.CategoryID inner join
dbo.aspnet_starterkits_Projects P on
CAT.ProjectID=P.ProjectID
Where TimeEntryUserID=(SELECT UserId FROM dbo.aspnet_Users WHERE
UserName=@UserName) AND
TE.TimeEntryDate=@WeekEnding
" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE dbo.aspnet_starterkits_TimeEntry
SET
TimeEntryDescription=@TimeEntryDescription,
TimeEntryDuration=@TimeEntryDuration,
TimeEntryDate=@TimeEntryDate
WHERE
TimeEntryID=@original_TimeEntryID">
<SelectParameters>
<asp:ControlParameter ControlID="UserList" Name="UserName"
PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="WeekEnding2" Name="WeekEnding"
PropertyName="Text" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="TimeEntryDescription" />
<asp:Parameter Name="TimeEntryDuration" />
<asp:Parameter Name="TimeEntryDate" />
<asp:Parameter Name="original_TimeEntryID" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" BorderWidth="0px"
BorderStyle="None" Width="100%" CellPadding="2" PageSize="25"
DataKeyNames="TimeEntryID" onrowdatabound="GridView1_RowDataBound"
onrowupdating="GridView1_RowUpdating" >
<Columns>
<%--<asp:CommandField ShowEditButton="True" />--%>
<asp:BoundField DataField="TimeEntryID" HeaderText="ID"
SortExpression="TimeEntryID" InsertVisible="False" ReadOnly="True"
ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="Project" SortExpression="ProjectName">
<EditItemTemplate>
<asp:DropDownList
ID="DropDownList1"
runat="server"
DataSourceID="sdsDdlProjectsEdit"
DataTextField="ProjectName"
DataValueField="ProjectID"
AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource
ID="sdsDdlProjectsEdit"
runat="server"
ConnectionString="<%&#36; ConnectionStrings:ttuser %>"
SelectCommand="SELECT ProjectID,ProjectName FROM dbo.aspnet_starterkits_Projects">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("ProjectName") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" SortExpression="CategoryName">
<EditItemTemplate>
<asp:DropDownList
ID="DropDownList2"
runat="server"
DataSourceID="sdsDDL2"
DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList>
<asp:SqlDataSource
ID="sdsDDL2"
runat="server"
ConnectionString="<%&#36; ConnectionStrings:ttuser %>"
SelectCommand="SELECT CategoryID,CategoryName FROM dbo.aspnet_starterkits_ProjectCategories WHERE ProjectID=@ProjectID">
<SelectParameters>
<asp:Parameter Name="ProjectID" />
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField DataField="TimeEntryDescription" HeaderText="Description"
SortExpression="TimeEntryDescription" ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="TimeEntryDuration" HeaderText="Hours"
SortExpression="TimeEntryDuration" ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField ApplyFormatInEditMode="True" DataField="TimeEntryDate"
DataFormatString="{0:d}" HeaderText="Week Ending"
SortExpression="TimeEntryDate" ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:CommandField ShowEditButton="True" HeaderText="Edit" ButtonType="Image" EditImageUrl="images/icon-edit.gif"
UpdateImageUrl="images/icon-save.gif" CancelImageUrl="images/icon-cancel.gif" />
</Columns>
</asp:GridView>

View 3 Replies

Forms Data Controls :: Dropdownlist In Gridview Gives Parameter Error?

Jan 23, 2011

I have a gridview with some text-box columns and one dropdownlist-column (Templatefield).

With the dropdownlist i wan't to be able to edit a cell in a row. I have read a lot on the web and i have folowing code. I only get a parameter error now, before i added the dropdownlist everything was ok.

This is my html:

[Code]....

This is my update-command in the class "TransactiesDAO"

[Code]....

Look at the line:

[Code]....

in the aspx code. I don't now what to type in the "Bind(...)" text.

With above i get error: Message=DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Subrubriek'. when trying to update the row.

When i delete the line "SelectedValue=" then i get folowing error:

It gives me folowing error:

ObjectDataSource
'ObjectDataSource1' could not find a non-generic method 'UpdateTransactie' that
has parameters: Rekening, Omschrijving1, Omschrijving2, Boekdatum, BedragBij,
BedragAf, Subrubriek, @ID_SR, ID

View 4 Replies

Forms Data Controls :: Gridview Is Showing The Edit Mode After The Edit Is Done

Mar 30, 2010

I have a grid view with edit and save buttons when I click on edit it is letting me edit it and if I click on save it is lettingme save the data that I have edited.

The thing is after save is done it is showing the data in edit mode i.e <edit item template > mode I am still seeing the textboxes if I refresh the page then I am seeing it normally.

How can I stop the gridview to show edit mode after the save is done?

View 4 Replies

Forms Data Controls :: Edit An Entire Column Instead Of Edit By Row Within A Gridview?

Apr 5, 2010

Can someone tell me if there is a technique to make an entire Column within an gridview (for example digits) editable (instaed of a single row) and update this column after changing values by press an Update-button?

A commercial solution is also o.k. with me, but, of course, a method to do it ourselve would be nice.

View 2 Replies

Forms Data Controls :: How To Edit GridView All Rows In Edit Mode

Dec 4, 2010

- I want to put multiple rows of a gridview into edit mode

- I have not found any easy method to accomplish this task. I found a way to programmatically put a gridview into edit mode, but in testing the code below it works for only 1 row at a time :

[Code]....

View 5 Replies

Forms Data Controls :: Master Detailed GridView Edit Selects The Wrong Row To Edit?

Mar 16, 2011

I have a page with 2 GridViews on it. The top GridView shows all the Bike Riders the bottom GridView shows all the Bike Lockers. I have set up both GridViews to be able to Edit the data. And the top GridView to Select.

When I click the Select buton on the top GridView I programically reset the DataSource for the bottom GridView to show the Locker for the Biker of the top GridView Selected.

So far everything works great. I select a Biker on the Top GridView and the Bottom GridView resets just showing one record for the bike locker.

The problem is that if I then click on the Edit button on the bottom GridView (The Bike Locker GridView) the GridView goes into the Edit Mode but it now shows all the Bike Locker records and the edit record is always the top record of the GrdView.

Here is my code Behind:

[Code]....

View 1 Replies

Forms Data Controls :: Change Edit And Cancel Link When In Edit Mode On Gridview?

Aug 18, 2010

How do I change these hyperlinks to say something other then Edit and Cancel?

View 4 Replies

Forms Data Controls :: To Use CustomValidator In GridView Edit Mode - Getting The "Object Reference." Error

Jun 9, 2010

I am attempting to use a CustomValidator control to validate a FileUpload control that is present in my Gridview's EditItemTemplate

[Code]....

I'm not calling the FileUpload control correctly, because I am getting the "Object reference..." error

View 9 Replies

Forms Data Controls :: Dropdownlist In The Edit Template

Aug 24, 2010

I have a transaction table with a field called product. There is a limited number of choices for product so I also have a product table. I am showing the transactions in a ListView with a dropdownlist for Product. The field Product can be blank (all works well then). The user can leave the field blank or they can choose from the dropdownlist. I am running into a problem with the dropdownlist in the Edit Template. No matter what the product is in the transaction file, I get a page error of "ddlEditProduct has a SelectedValue which is invalid because it does not exist in the list of items". I have verified the product does exist in the product table.

<asp:DropDownList ID="ddlEditProduct" runat="server"
DataSourceID="dsProduct"
DataTextField="Product"
DataValueField="Product"
AppendDataBoundItems="true"
SelectedValue='<%# Bind("Product") %>' >
<asp:ListItem Selected="True"></asp:ListItem>
</asp:DropDownList>

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved