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


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

how to in Insert database NULL if drop down list item is not selected ?

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
 
hi,   on my aspx I have the below DDL   <asp:DropDownList ID="ColorDDL" runat="server" DataSourceID="ColorObj"                                                 DataTextField="Size" DataValueField="BustId" Width="150px"                                                 AppendDataBoundItems="True">                                                    <asp:ListItem Value="-1">(Optional)</asp:ListItem>                             &n


View Complete Post


More Related Resource Links

Updating a List item field value in a SPD Workflow is setting Date fields to null

  
Hello everybody,I faced a very weird behavior while creating a workflow in SPD against a Document Library.Here is the case:1- Create a document library in sharepoint site.2- Add a custom column of type DATE.3- Upload any document to the library4- Edit the item metadata and set the custom date field to any date you want.5- Now using sharepoint designer, create a very simple Workflow with only one action that updates the current item "Title" field to any value. (Note: In my case I set the workflow to start manually and not automatically)6- Save the workflow and then start it on the uploaded item.7- Now check the value of the date column after the workflow is finished.8- You will see that the Date field is Empty... (very weird)Notes:   1-This behavior will not appear on a standard list. it is only appearing in a Document library.  2- I am using WSS 3.0 SP2 + MOSS 2007 SP2. Also SharePoint designer 2007 SP2Did anyone face this situation and does it have a fix, or am I doing something wrong here... Please help.Regards,Maheed

How to get selected text of a drop down list in MVC?

  
I aggressively googled around, but could not find the information I am looking for.  I know how to populate a dropdownlist using my view model and Html.DropDownListFor helper method.Suppose the drop down list contains U.S. stateId and stateName key value pairs.  Suppose my ViewModel looks likepublic class MyViewModel{      public IList<State> States {get; set;}      public int SelectedStateId {get; set; }}public class State{     public int StateId {get; set; }     public string StateName {get; set; }}Now, in my controller's action method:[HttpPost]public ViewResult Index(MyViewModel  myViewModel){     // This following line seems to work fine, myViewModel automatically      // picks up the selected item of the drop down list.  How does this work?      // Is this the so-called model binding?      int selectedStateId = myViewModel.SelectedStateId;      // But, then, how do I get the selected state name?     string stateName = ??????????????     ... ... }Do I have to change my implementation of my view model?  In any case, how to get the selected item text of the drop down list?  Any hint?  Thanks a lot.

How to update selected item state in the list box by clicking a button?

  
I created a listbox menu to browse through content by clicking items in the listbox. I also created ‘back’ and ‘forward’ type of navigation to browse through the same content based on the browsing history. I load content into frame and accessing the browsing history with NavigationCommands.BrowseBack and BrowseForward Properties. It is working great. However, I need to indicate a selected state of the listbox item related to the content shown in the frame while browsing with Back/Forward buttons. I have a hard time binding that property. What is the correct way to bind selected state of the listitem in this case? Thank you in advance. XAML: Button <Button x:Name="NavBack" Content="" HorizontalAlignment="Left" Margin="20,0,0,0" Style="{DynamicResource BackButtonStyle}" VerticalAlignment="Top" CommandTarget="{Binding ElementName=ContentFrame}" Command="{x:Static NavigationCommands.BrowseBack}" SnapsToDevicePixels="True" IsEnabled="{Binding CanGoBack, ElementName=ContentFrame, Mode=OneWay}" > XAML: Listsbox <ListBox x:Name="Nav_ListBox" Margin="0,18,0,0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Background="#FFF2F2F2" ItemsSource="

How to apply color to selected number of items in check box list and drop downlist

  
Hi all,    I want to apply color to selected number of items in checkbox list and seleted number of items in drop downlist for e.g color red for few items and black (default). I have a bit value set in data base so if bit is set to 0 then red and if 1 then back. Please help me.  

Drop Down List Selected Value problem ...

  

Hello,

I created an Html Helper that renders 3 drop down lists (Day, Month and Year) for a field of type DateTime:

    public static MvcHtmlString Date(this HtmlHelper htmlHelper, String name, IEnumerable<SelectListItem> days, IEnumerable<SelectListItem> months, IEnumerable<SelectListItem> years, IDictionary<String, Object> htmlAttributes) {

      if (String.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "Name cannot be null");

      StringBuilder fields = new StringBuilder();

      if (days != null)
        fields.Append(htmlHelper.DropDownList(String.Format("{0}.Day", name), days, String.Empty, htmlAttributes));

      if (months != null)
        fields.Append(htmlHelper.DropDownList(String.Format("{0}.Month", name), months, String.Empty, htmlAttributes));

      if (years != null)
        fields.Append(htmlHelper.DropDownList(String.Format("{0}.Year", name), years, String.Empty, htmlAttributes));

      return MvcHtmlString.Create(fields.ToString());     

    } // Date


And I have a DateFor extension:

    public static MvcHtmlString DateFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<S

Insert an item in a Lookup column's source List from the NewForm

  

When Lookup Column of a List does not contain a value in the DropDown menu can it be added/inserted into the source Lookup List from the NewForm without leaving the NewForm? 

Is there code or example how to insert the Item in the source List, then refresh/repopulate the Lookup Column's DropDown menu (in the NewForm)?

 


Refreshing list after insert item

  
Hi, im having problems in a custom list, i develop a custom form with sl and configure a content type to use this form as a newform item, when i clic on new item all its fina my custom form is opened and i can insert the item the thing is when i close this form the custom list behind dont show the new item i mean this list don refresh by itself i have to press F5 to reload the page and see my new item in the list is there a way to make this automatically ? thanks in advance.

list refresh after insert item

  
Hi, im having problems in a custom list, i develop a custom form with sl and configure a content type to use this form as a newform item, when i clic on new item all its fina my custom form is opened and i can insert the item the thing is when i close this form the custom list behind dont show the new item i mean this list don refresh by itself i have to press F5 to reload the page and see my new item in the list is there a way to make this automatically ? thanks in advance.

Refreshing list after insert item

  
Hi, im having problems in a custom list, i develop a custom form with sl and configure a content type to use this form as a newform item, when i clic on new item all its fina my custom form is opened and i can insert the item the thing is when i close this form the custom list behind dont show the new item i mean this list don refresh by itself i have to press F5 to reload the page and see my new item in the list is there a way to make this automatically ? thanks in advance.

Databound dropdown list inside detailsview filtered dependent on selected radiobuttonlist item

  

It's driving me mad.  I have a detailsview bound to an sqldatasource. One of the items on the data table is to get its value from a dropdown list, so I created a template field and entered a dropdownlist, then bound that to a second datasource with the selection values in it. As the values can be male or female related, I have an unbound radiobuttonlist above the dropdownlist with two values - male or female - retunring an d"m" or an "f" and I want to use this to filter the records coming from the second data source for the dropdownlist.

I can't use a normal SQL control parameter on the datasource as the selector (the male/female radiobuttons) are in the detailsview and therefore "invisible".  I set up a normal control parameter with "none" as the type.  I then set the "autopostback" value to "true" for the male/female radio buttons and tried writing in the code-behind for the "maleorfemale_SelectedIndexChanged" event and using debug lines revealed that I was getting the "m" or "f" I needed by using "findcontrol", so that's fine.

I also tried adding in the "selecting" event for the second datasource to use the value of the radiobutton item, but although the "selecting" event fires

Dropdown list value to insert into database

  

I have a dripdownlist

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="NameSource"
           DataTextField="Choice" DataValueField="Appliers" AutoPostBack="True">
    </asp:DropDownList>

I want to insert into database with the following code. I want the  Appliers instead of Choice to be inserted. Now this code insert the Choice field only. How should I modify this code ? Thanks

e.Command.Parameters("Name").Value = DropDownList1.SelectedValue

I tried SelectedItem it becomes error too... help...


How to read a NULL value sharepoint list item

  

hi guys,

im having trouble pulling some specific information out from sharepoint list item. im doing a asp.net form and saved all user inputs into sharepoint list. if all information are there, my code works fine, if some colume is missing(the scenera requires to do that), it will return a  System.NullReferenceException: Object reference not set to an instance of an object exception. How can i read a null item, and maybe simply assign it to a string such as "NO VALUE", something like that?

i've tried all methods that i can think about, such as system.DBNull.value, or string.empty, or just null.

code is here: this is the save to list code:

private void SaveToTTCVIPList(SPWeb web)
    {
      try
      {
        TTCVIPList = web.Lists["TTCVIP"];
      }
      catch
      {
        TTCVIPList = AddList(web, "TTCVIP", "List for TTCVIP user's information", "Custom List", true);
        buildTTCVIPList(TTCVIPList);
      }
      SPListItem item = TTCVIPList.Items.Add();      
      ...      
if (this.txtJointHolderName.Text == System.DBNull.Value)
      {
        item["Joint Holder Name"] = string.Empty;

INSERT NULL value in SQL database when there is no file to upload

  

Hi,

I've been working on a code that allows users to upload images (jpgs) as an optional field. Alhough the uploading works, I'm struggling when the user doesn't have an image to upload. I can't seem to find the way to NOT insert binary data into my database, I just want an NULL value when there is no image.
I get this error message: ...expects parameter @Image, which was not supplied.

 

Here is the code: 

Sub InsertItem()

Dim imageData As Byte() = Nothing
Dim MIMEType As String = ""

If

Insert URL of item created in new list item

  

I have a calendar list that when an item is added I need to add a list item to an issues list and include the url of the item added in the original calendar list.  I have the workflow that creates the list item in the issue list, but how can I obtain the URL and append that to text in the "Comments" column?

Any help would be greatly appreciated.


David Dye http://sqlsafety.blogspot.com/

How do I pass the Selected Value of my Drop Down List

  

I added 3 values on DropDownList controls. ID= DropDownList1. If a user selects a value from the DropDownList, I'd like to insert the value on my DB (DB = Test) and in Column (Column = LastName). Below is the code I get when I double click on the DropDownList.

 

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

 

End

Drop down remove selected item on post back

  

Hi ,i have a place order form and i have a drop down list that contains list of items

whenever i add item (for example item1)  to place order and click add another item button,

i need to remove  (item1 ) from drop down list to avoid dupplicate insert in sql table

or mayb need to fill the drop down but without (item1) cause i already selected it


it s kind of validation


i am using sql datasource to fill the drop down list of items




How to remove blank item from infopath form in drop down list

  

Hi,

how to remove the blank item from the drop down box which is used in infopath form..

 

Regards,

siva


Categories: 
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