I have a drop down list that is populated in the page load event from a database table. The drop down has a DataTextField set to a project name and the DataValueField set to the project id (interger). Later I change the dropdowlist selected item with this code in the selectedindexchanged event of a gridview
Does Changing the drop down list with this code cause the DataValueField property to change to the correct Project ID number also? If not is there a better way to do this? actually this code seems to be adding an additional item to the list so that the project i set with this code is listed twice so I don't think my code is correct
I have a databound dropdownlist and have a problem with the default value it selects.When I attempt to edit a record the dropdownlist shows the first value in the list rather than the current value. I want the dropdown list to display the current value.
I'm sure this is very simple but I'm very new to ASP.NET.
I have a simple databound dropdownlist. On top, I have a default selection, '--Please Select--', followed by another default selection, '-- Other --'. Here's the script:
[Code]....
Now, my user wants the '--other--' selection to appear on the BOTTOM of the dropdown as opposed to right sfter '--Please select--'. How do I accomplish this?
How would I go about displaying a databound dropdown list in a property grid, i.e. a dynamic list that can be used to set the value of an individual property?
I wanna set a default value in dropdown list when i change in list.....e.g.
I have a dropdown which i have placed in Gridview templates and there is another dropdown jst above that grid....i want...when i change in above dropdown and select a value from that...then that value should be apply in below gridview's dropdown...
As i am selecting 'A' then Gridview's All Dropdowns default value should set 'A'
I am stuck at this point "Displaying a dropdown list of Categories with a --None -- Option. I want the gridview control to display 2 dropdown list one in read-only mode and the other in edit mode. When a record is in read-only mode, the dropdownlist's enabled property will be set to false."When it's on a read-only mode, it doesn't display the selected Category. it shows but the "No Category". When i click on edit to edit or change category, it doesn't display the selected category.
The example is given below( I am reading the book Sams Teach yourself ASP.NET 2.0 by Scott Mitchell. page 628)
<asp:Label ID="UserIdValue" runat="server" Visible="False"></asp:Label> <asp:SqlDataSource ID="picturesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Pictures] WHERE ([UserId] = @UserId) ORDER BY [UploadedOn] DESC" DeleteCommand="DELETE FROM [Pictures] WHERE [PictureID] = @PictureID" InsertCommand="INSERT INTO [Pictures] ([UserId], [CategoryID], [Title], [Description], [UploadedOn]) VALUES (@UserId, @CategoryID, @Title, @Description, @UploadedOn)" UpdateCommand="UPDATE [Pictures] SET [UserId] = @UserId, [CategoryID] = @CategoryID, [Title] = @Title, [Description] = @Description, [UploadedOn] = @UploadedOn WHERE [PictureID] = @PictureID"> <DeleteParameters> <asp:Parameter Name="PictureID" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="UserId" /> <asp:Parameter Name="CategoryID" Type="Int32" /> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="UploadedOn" Type="DateTime" /> </InsertParameters> <SelectParameters> <asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text"/> </SelectParameters> <UpdateParameters> <asp:Parameter Name="UserId"/> <asp:Parameter Name="CategoryID" Type="Int32" /> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="UploadedOn" Type="DateTime" /> <asp:Parameter Name="PictureID" Type="Int32" /> </UpdateParameters> </asp:SqlDataSource> <br /> <asp:SqlDataSource ID="categoriesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId)"> <SelectParameters> <asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text" /> </SelectParameters> </asp:SqlDataSource> <br /> <asp:SqlDataSource ID="maxPictureIDDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT MAX(PictureID) FROM Pictures WHERE UserId = @UserId"> <SelectParameters> <asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text" /> </SelectParameters> </asp:SqlDataSource> <br /> <asp:Label ID="cannotUploadImageMessage" runat="server" Text="The photo could not be added to your album either because you did not specify a file to upload or the file specified was not a JPEG image with the file extension .JPG"></asp:Label> <br /> <asp:DetailsView ID="dvPictureInsert" runat="server" DataSourceID="PicturesDataSource" Height="50px" Width="125px" AutoGenerateRows="False" CellPadding="4" DataKeyNames="PictureID" DefaultMode="Insert" ForeColor="#333333" GridLines="None"> <AlternatingRowStyle BackColor="White" /> <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" /> <EditRowStyle BackColor="#2461BF" /> <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" /> <Fields> <asp:TemplateField HeaderText="Picture"> <InsertItemTemplate> <asp:FileUpload ID="imageUpload" runat="server" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="imageUpload" Display="Dynamic" ErrorMessage="There was no file selected" ValidationGroup="PictureAdd"></asp:RequiredFieldValidator> </InsertItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Category" SortExpression="CategoryID"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID="pictureCategory" DataSourceID="categoriesDataSource" runat="server" DataTextField="Name" DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>' Visible='<%# Bind("CategoryID") %>' AppendDataBoundItems="True"> <asp:ListItem Selected="True" Value="">-- Select Category --</asp:ListItem> </asp:DropDownList> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Title" SortExpression="Title"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="you must provide a name for the title" ValidationGroup="PictureAdd"></asp:RequiredFieldValidator> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("Title") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Description" SortExpression="Description"> <EditItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'
I've tried to wrap up my problem with a complete example below - the original problem is part of a jQuery plug-in that I'm writing to extend the behaviour of an ASP.NET ajax application I already have.
The aspx page below has one drop down list which is marked for auto post back. I've also bound a change event using jquery (which ultimately I will swap for a .live() event to maintain the binding after the update panel refresh.) The problem is, when the jQuery event is bound I see two ajax begin requests and page_loads fire but only one ddlTest_OnselectedIndexChanged event. One of the page loads is malformed too - the content-length states it's about 300 bytes long whilst the totalBytes is 0 and form data empty. This does not happen if I bind to the click event of a button.
GridView gv = new GridView(); gv.AutoGenerateColumns = true; gv.DataSource = listOfEntities; gv.DataBind(); // set alignment for description column gv.Columns[0].ItemStyle.HorizontalAlign = HorizontalAlign.Left;
On the last line I get index was out of range error, and indeed if I inspect the GridView there's no columns yet. The Entity I am binding has 2 properties and they get rendered OK if I don't try to align them.
Is there a way to do this without having to dynamically assign a delegate to the DataBoundEvent of the gridview?
I have 2 drop down lists.I have a very simple dropdown list #1 that diplays a title and holds an id value which is a GUID.I know it is getting this value and sending this value as I tested sending it to a label.I have the dropdown list #1 to autopostback to dropdown list #2 that "Is supposed to get" another title and value based on the GUID value of the first dropdown list. for some reason it wont return anything. I have done 100's of these but never based off a guid value.I assume the value needs to be converted to guid before selecting it in the second dropdown list.How can I do this? or is there something I am missing?
Does anyone know how to do this so when I select something the 1st dropdown and the 2nd one becomes visible and populates list from a Select statement. I really need help on how to do in an aspx and not on the code behind page.
I Have the gridview control with 2 dropdown list and 2 text boxes,When the textbox chnaged event happen 1 row will create and the dropdown back to initial values( its not retaining the selected values),I am binding the control after text changed method,Is there any properties needs to be set or any other way we can retain the values in postbacks?
I have a category and a subcategory column in a Jqgrid. I have enabled inline editing, both category and subcategory are dropdownlists columns (edittype:'select'). I need to filter the subcategory list based on the selected category. I wonder how can I acheive this functionlity? I tried the below event but its not working for me
afterEditCell: function(rowid, celname, value, iRow, iCol) { //to do here }
the above event doesn't get fired. my all column are editable
I have a ListView with a template, it puts a bunch of data in, like X Y Z.
I want to hide show some columns based on criteria, so I have ItemDataBound event, but I don't know how to get the actual listview row so I can do things to do it.
I need to pull a list of supplies from a db table and list them along with two textboxes (one for quantity, and another for manufacturer)
so the list would look something like this.
checkbox for supply 1 | Quantity | Manufacturer checkbox for supply 2 | Quantity | Manufacturer ..
I also need to store all of the checked items in a db table. I'm not sure how i should go about doing this. I've heard some talk about a repeater control being useful but i've not come across any examples that do this type of thing.
i have multiple drop down lists and using the DataBount event to insert an initial value to populate the drop down list, which does exactly what i want it to do. however, now i have put a required validation control on it and the validation never gets triggered because of my value i insert using this code below. anyway i can get my validation control to avoid the databout value?
How can i generate dropdown lists based on what has been selected in the checckbox list. Below is an example of what i need. if the user selects the options day, lotID and waferID, then 3 cascading dropdown lists should be displayed. And then a gridview displays data based on what has been chosen in the dropdown lists.
Day LotID SlotID WaferID VendorID ToolID LocationDetected ProcessStep Stage Precipe WaferStartMaterial WaferStartVendor WaferStartLot WaferDiameterCOA WaferMapTitle BreakPoint BreakpointSide BreakpointMeasurement
Clicking the label of a drop down list, re-sets the selected value to the first item in the list. This has a history of causing data entry problems when users accidently click on the label.
In the below example ddlContactType has a selected value as 'PRIMARY' and whenever i click on the lblContactType Text, the dropdown box Selected value is changing to "Select One" Text.
How to prevent this one. It should be on PRIMARY Only.
I'm trying to progam a strongly typed "Create" view using MVC 3 and razor. I want the user to be able to select a customer from a dropdown list (I populated this from my database using ViewBag in the controller). When the user has selected a customer I want a separate dropdown list to generate a list of dogs belonging to that customer related by the customerID in the database. The create button on the form will then take both of these values along with the the other fields and save it to the database.
I have to modify a page so that depending on who views the page i will show client or client Type, its easy enough to change the text but I cant see how to change the datafield