.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Populate dropdownlist in Edit mode programatically

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net

I'm trying to programatically populate some dropdownlists inside a formview in EDIT mode, like this below.

 Dim FVM As String = FormViewMemberProfile.CurrentMode.ToString

        If FVM = "Edit" Then

            Dim ddlDays As DropDownList = CType(FormViewMemberProfile.FindControl("ddlDays"), DropDownList)
            Dim ddlYears As DropDownList = CType(FormViewMemberProfile.FindControl("ddlYears"), DropDownList)

            Dim i As Integer = 1

            For i = 1 To 31

            Dim k As Integer

            For k = 1930 To 2008

        End If

I orginally had this running as part of the pagelaod event, but I'm thinking that b/c the page loads first, it doesn't populate the fields in EDIT mode until after the data is saved, and then page is reloaded. Now it knows it's in "Edit" mode. Am I thinking clearly here? Not sure if this is the order of things... Anyhow...

So I thought I should just use a formview_modechanged (or similar event) so when the user switches modes, it populates the fields - but I'm not sure which event I should use. I've tried "Modechanging", "modechanged", "prer

View Complete Post

More Related Resource Links

Accessing a row's dropdownlist values AFTER the gridview control is in Edit mode

Hello, I have a gridview control. When it goes into Edit mode, there are 3 dropdownlists in one cell that are populated by separate stored procedures during the RowDataBound event. The 1st dropdownlist's value is used as a parameter to determine what the 2nd dropdownlist is populated with. The 2nd dropdownlist's value is used as a parameter to determine what the 3rd dropdownlist is populated with. Everything works fine when the row is first put into Edit mode. While I'm in Edit mode and I change the selection in the 1st dropdownlist, how do I access the control so I can feed this new parameter to the 2nd dropdownlist? I have the first 2 dropdownlists set for AutoPostBack so that the Page_Load event is fired when the user changes a value. I know how to get access to these controls via the FindControl method when the row is being databound but how do I find the control during the Page_Load event? Thanks for any help!!!   Penny  

Populate textbox in FormView Control in Edit Mode with querystring

Can someone please tell me what I am doing wrong here. I am simply trying to get a querystring value and pass it to a textbox in a formview with the default view set to edit mode.     Protected Sub fv_Detach_Engine_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles fv_Detach_Engine.DataBound        If fv_Detach_Engine.CurrentMode = FormViewMode.Edit Then            Dim tbx_IDProfileAccount As TextBox = TryCast(fv_Detach_Engine.FindControl("tbx_IDProfileAccount"), TextBox)            If tbx_IDProfileAccount Is Nothing Then                tbx_IDProfileAccount.Text = Request.QueryString("IDProfileAccount")            End If        End If    End Sub  

Moved from WinXP to Win7 - don't see choice to open file in read only or edit mode


I just recently moved from Win XP Pro SP3 to Win 7 32-bit Pro. I am logging into domain X normally. Our Sharepoint 2007 server authenticates only on domain Y. So I start Internet Explorer with "run as different user" and provide my domain Y credentials. All fine. 

In win XP, after I did this, when I click on an Excel file on Sharepoint, I would get a dialog asking if I wanted to check out and edit or open as read only. 

In win7, I don't get that choice. The file simply opens, and I get a bar at the top which allows me to check out the file if I wanted to. 

How can I restore the functionality I used to have, with the dialog for checking out the file before opening it?

Not always prompted for read-only or EDIT mode, when opening files with IE7, Sharepoint 3.0

Hello Everyone,   We use Sharepoint 3.0 and when I click on a document I get a pop up prompt that asks me whether I want to open the file in READ-ONLY or EDIT mode.   I use a machine with XP Pro that is running IE7.   A user called me today, also running IE7, and when he clicks to open a Sharepoint file he gets a different prompt - a simpler one that just offers OPEN or SAVE.   I don't care that his prompt looks different - the problem is that he is able to open the file, make edits, but then when he closes the file (using Excel) he isn't able to save his changes.   Excel only provides a save-as option for him.   This isn't a permission problem with his ID.   When I login to our Sharepoint 3.0 system as him, with his password (from my machine), I get the usual Read-Only / Edit prompt and when I open a file in EDIT mode I am able to save my changes with no problem.   Any thoughts on this?   Chris

Questions about setting dropdownlist selection programatically

I don't understand some things about setting the current selection of dropdownlists from code. I have a dropdown list of people's names where the Value is a Person_ID.  This gets loaded from SQL, and I added an Item which is "Please select..." to the top of the list and gave it a value of 0.  AppendDataBoundItems is true.   If I want to select an item from code can I use dropdownlist.SelectedValue=8 (for example)? Do I also have to set the SelectedItem.Text or does tha above do that for me? Can I instead set the SelectedIndex to some number if I happen to know it?  Will that set the SelectedValue and SelecteItem for me? If I want to set the list back so that nothing is selected (and Please select... shows) should I set SelectedIndex=0?  Is that the same as setting SelectedValue=0 in this case (since "Please select" has a value of 0)? I guess I'm confused on which of these 3 properties I should be using, to select an item (or deselect all items) in the list, using code. Thanks.

How to use parameter from Dropdownlist to populate Rep. Table

I successfully have populated a dropdownlist from a database. Now I need to create a sort of a Master/Detail situation - based on the selection in the DropDownlist, I need to populate a Repeating table. I just can't find any examples or tutorials on how to do this. I've tried stuff till my fingers were bleeding. Can someone help me figure this scenario out, please?

Need more font size options in browser edit mode

Is there a way to have a different font size other than the drop down menu of Editing Tools > Format Text of: 8, 10, 12, 18, 24, 36, 48, 72 pt ?   As a designer, I feel handcuffed with just these options. 

Gridview edit mode - What event does enter key call?

I have sort of a very specific problem.  I have a gridview with a few different template columns and a commandfield with the standard "edit" link.  There is no sqldatasource associated with it at all.  In the code, I pull some data from an sql database into a datatable and set the gridview's datasource to be the datatable.This all works fine.  When I hit the "edit" button, the standard textbox shows up where it needs to so that I can edit the data.  The problem is the updating portion.  I have programatically removed the "update" button and left the "cancel" button for design reasons. I want the user to be able to hit "enter" in order to update the data in the data table.  Then, when they're ready, they can click a submit button which will extract the data from the datatable and update the database.I'm having trouble with this 'enter key' business.  When you edit the data and hit "enter" while in edit mode, the page posts back, and the previous values are placed in the gridview.  What event was just  called?  I need a way to take what the user put in and place it in my datatable.  What are my options?Thank you. 

hide EDIT mode from the ribbon

Hi, I am creating a page in SPD 2010 contain custom form that insert items in a list (Poll).  the problem is when i browse the page, by default the ribbon goes to the edit mode. please see the snapshot http://www.exceeditacademy.com/pdf/issue.jpg my question is: - how to force Ribbon to go to the browse mode dirrectly ? or - How to hide the edit mode from the ribbon ? thx

Have templatefield in edit mode and datasource defined in code behind

Is this possible? Some sample code:<asp:GridView ID="gvConcerns" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"> <RowStyle BackColor="#EFF3FB" /> <Columns> <asp:TemplateField HeaderText="Number" Visible="true" SortExpression="Number"> <EditItemTemplate> <asp:Label ID="lblEditNo" runat="server" Text='<%# Eval("number") %>'></asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Part" Visible="true" SortExpression="part"> <EditItemTemplate> <asp:Label ID="lblEditPart" runat="server" Text='<%# Eval("part") %>'></asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="List" Visib

Want to show FormView in Edit mode with specific table columns depending on their Genre??

hi, I have  a table in my database called "Profiles". This holds data on Female and Male personal characteristics. On my aspx, I have a formview in edit mode which is binded to an object data source with a GetDataByUserId Select method which retrieves data from the "Profiles" Table via a DAL. The "Profiles" table has some columns which relates to females only and some just males and some are generic to both. See example below     UserId - / of Type GUID GenreId /  of Type BOOL. Hip Size (For females) Dress Size ( For Females) ChestSize (For Men ) TrouserSize (For Men) Weight ( For both )   When the User logs in , they go to an update Page which has the Formview in Edit Item Mode and contains drop down Lists which are binded to the Users Selected Value. The DDL are in turn bound to their related table such as HIP, Dress, Chest, Trouser etc. Objective If a female user logs in I just want to show them the (Hip Size) DDL  and DressSizeDDL in the Edit item template of the formview and not the ChestSize DDL or  TrouserSize DDL. At present the GetProfileByUserId returns all colums from the table My question is how do I do this and just show DDL which are relevant to the Female or Male Only. In some cases the user may not have selected an item in the previous form so they could also be

DetailsView error "must be in edit mode to update a record" when I have set edit mode in code behind

Hi,I have a DetailsView within an UpdatePanel.  I programmatically put the DetailsView into edit mode, change the fields then call the UpdateItem method which causes the "must be in edit mode to update a record" exception.  Am I missing something blindingly obvious? <asp:UpdatePanel ID="upSpecificShout" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" > <ContentTemplate> <asp:DetailsView ID="dvSingleShout" DataSourceID="sdsSingleShout" runat="server" AutoGenerateRows="false" OnDataBound="SetDVIcons" HeaderStyle-CssClass="noDisplay" DefaultMode="ReadOnly" AutoGenerateEditButton="true" OnItemCommand="dvItemCommand"> <fields> <asp:TemplateField ShowHeader="false"> <ItemTemplate> <asp:Panel ID="dlSpecificDetailsViewPanel" runat="server" CssClass="i_am_a_shout"> <h2><asp:LinkButton ID="lblShoutTitle" runat="server" Text='<%# Bind("Shout_Title") %>' On

DropdownList Selection to Populate TextBox

I have a dynamically generated dropdownlist, that lists e.g. Company Names. I want to be able to select a particular Company and display associated information e.g. Name, Address, City, State... etc. in text boxes adjacent to the list. I am trying to fire the following code from the dropdownlist "OnSelectedIndexChanged" property, but cannot 1) get the code to fire upon selection, and 2) populate the text boxes... any suggestions are appreciated!! Thanks CODE:     Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Facility.SelectedIndexChanged Dim FacilityAddressDetail As String  Dim FacilityAddress2 As String  Dim FacilityCity As String  Dim FacilityState As String  Dim FacilityZip As String Dim   FacilityAddressDetail = FacilityAddress2 = FacilityCity = FacilityState = FacilityZip =       mySettingsSIC = AppSettings   dgiSelectedIndexChange As DataGridItemFor Each dgiSelectedIndexChange In myDataGrid.ItemsCType(dgiSelectedIndexChange.FindControl("FacilityAddressDetail"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityAddress2"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityCity"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityState"), TextBox).TextCType(dgiSelec

Put outer-gridview in non-Edit mode when user edits inner-Gridview

using vb.net/asp.net 2005.(sorry last post I had the grids reversed, what I meant to say is this:I have an outer gridview I'll called "Outer" and an inner-gridview inside that I'll call "inner".There are times when the user will put Outer into edit mode and then put Inner into edit mode and change a value in Inner.  The user is not supposed to be able to do that.So when the user wants to edit Inner I need to change the edit mode of Outer so that Outer is Not editable.   EX: I want to do something like this but not sure in which event of outer to do it:'event fired when user puts inner gridview into edit mode Protected Sub Inner_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles Inner.RowEditing 'put outer gridview into non-edit mode Outer.EditIndex = -1 End Sub Does anyone know how to do this, is this the right event?  Also I assume I have to rebind the gridview?thanks,MC

How to put a TreeNode into Edit mode and make the text unselected

I have a c# app in which I would like to allow the user to enter new nodes in a TreeView control without having to use the mouse. I am able to intercept keystrokes in OnKeyDown, and the following code is working successfully: TreeNode newNode = new TreeNode( e.KeyData.ToString() ); Nodes.Add(newNode); LabelEdit = true; newNode.BeginEdit(); The problem is that the first letter in the node being edited is selected, which causes the following keystroke to replace the selected character.  Typing "HELLO" results in "ELLO", unless the user first presses the right-arrow key to deselect the selected first character. I tried setting e.Node.IsSelected = false in OnBeforeLabelEdit, but cannot because the IsSelected property is read-only. How can I programatically deselect the first character and position the edit cursor after the first character?

DataList/FormView won't populate DropdownList

I have a ddl inside the formview that I can't figure out how to wire up properly. The formview contains detail info, but the ddl needs to list the entire set to items. Then I want the ddl's selected value be set from the recordset intended  for the formview. I think it's just a timeing issue s I would like your help. Thanks, - EJM. Here my code somewhat reduced to save space...<asp:DataList Width="700" ID="DlMembers" runat="server" DataKeyField="Ident" OnItemCommand="DlMembers_ItemCommand" OnDeleteCommand="DlMembers_DeleteCommand" > <HeaderTemplate> <table border="1" cellpadding="2" cellspacing="0"> <tr align="left" valign="top"> <th nowrap>First Name</th><th nowrap>Last Name</th><th nowrap>Address</th><th nowrap>Email</th><th nowrap>Home Phone</th><th nowrap>Work Phone</th><th nowrap>Cell Phone</th><th nowrap>Position</th><th nowrap>Admin</th><th nowrap>Comments</th><th> </th><th> </th></tr></HeaderTemplate><ItemTemplate>

Populate DropDownList in InsertItemTemplate after insert

I thought this one would be easy, but no go. What I am trying to do is the following: I have two DropDownLists in my InsertItemTemplate, each bound to its own datasource. After the fields in this form have been filled out and the ItemInserting event fires, I rebind the ListView to its datasource, but the DropDownLists turn out empty. I tried to bind them in the ItemInserting event and it seems they get filled, but nothing shows up in them when the page loads. I also tried to fill them in the ItemDataBound event, but the e.Item.ItemType == InsertItem doesn't do it. What is the solution?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend