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


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

DropDownList in DataGridView with separate datasource

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :Windows Application
 
Here is my problem. I am using a DataGridView and have a master table which contains values which different tables related to the master data, i.e. StatusID =1 in master table = TrailerStatus (1, 2, 3, 4 and their descriptions) are in a related table.  I am able to retrieve the values from Table B 1 = Empty, 2 = Rejected, 3 = Onsite, etc.  However, I don't know how to relate the master table StatusID = 1 to default my dropdown list from the relational table 1, 2, 3, 4. I have been fighting with this for quite some time and just have not found a solid example of how to do this.  I actually have two dropdownlists which will need to be correctly wired in order for my application to work. This will also be an editable dataGridView but I will tackle that challenge once I get this first hair plucked from my butt. Any help would be greatly appreciated.  I am able to insert code from the aspx source but not sure that would help at this point. There is some code-behind which doesn't work at all pertaining to a ;;     gvSCACDetail_RowDataBound   ;; but I dont' think I can even get the code to compoile when this is not commented out. Here are some of the details: <td style="width: 700px; height: 20px"> <asp:GridView ID="gvSCACDetail" runat="server" AutoGenerateColumns="False" AutoGenera


View Complete Post


More Related Resource Links

Separate DataSource for DropDownList in DataGridView

  
Here is my problem. I am using a DataGridView and have a master table which contains values which different tables related to the master data, i.e. StatusID =1 in master table = TrailerStatus (1, 2, 3, 4 and their descriptions) are in a related table.  I am able to retrieve the values from Table B 1 = Empty, 2 = Rejected, 3 = Onsite, etc.  However, I don't know how to relate the master table StatusID = 1 to default my dropdown list from the relational table 1, 2, 3, 4. I have been fighting with this for quite some time and just have not found a solid example of how to do this.  I actually have two dropdownlists which will need to be correctly wired in order for my application to work. This will also be an editable dataGridView but I will tackle that challenge once I get this first hair plucked from my butt. Any help would be greatly appreciated.  I am able to insert code from the aspx source but not sure that would help at this point. There is some code-behind which doesn't work at all pertaining to a ;;     gvSCACDetail_RowDataBound   ;;but I dont' think I can even get the code to compoile when this is not commented out. Here are some of the details: <td style="width: 700px; height: 20px"><asp:GridView ID="gvSCACDetail" runat="server" AutoGenerateColumns="False" AutoG

Problem Binding DropdownList in a gridView to a datasource

  
I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).<asp:TemplateField HeaderText="Category"> <ItemTemplate> <asp:DropDownList ID="Cat" runat="server" SelectedValue='<%#Bind("CATEGORY") %>' > </asp:DropDownList> </ItemTemplate> <FooterStyle BorderStyle="None" /> <HeaderStyle BorderStyle="None" /> <ItemStyle BorderStyle="None" /> </asp:TemplateField>How do I do that? thanks in advance!

binding dropdownlist to datasource C#

  

 I have the following code in which I am trying to use a dropdownlist to update values in a gridview. I having trouble getting the datasource to bind to the dropdownlist

here is my code:

protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
        {           
                if (e.Row.RowState == DataControlRowState.Edit)
                {
                    DropDownList DropDownList1 = new DropDownList();
                    string Query = "SELECT DISTINCT STATUS FROM VW_MSG_VIEW";
                    DataSet dt = new DataSet();
                    OracleCommand cmd1 = new OracleCommand(Query, con);
                    OracleDataAdapter sqlDa = new OracleDataAdapter(cmd1);
                    sqlDa.Fill(dt);
                    DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
                    ddl.DataSource = dt;
                    ddl.DataValueField = "STATUS";
                    ddl.DataTextField = "STATUS";
                    ddl.DataBind();
                  } 
         }


I am getting nullreference exception on line ddl.DataSource = dt;

 

Thanks for any help


Populate a dataGridview based on select an item in dropdownlist!

  

Hello all!

In window form,  there are two comboBoxs named cbo1, cbo2 with populate the same items in the dropdownlist as following: For examples,

Class A

Class B

Class C

I like to populate the data into two dataGridViews named dgv1, dgv2 based on selecting an item in two dropdownlists. The rules is if I select an item in the cbo1 to populate data in dgv1, and cbo2 with hide (remove) an selected item from cbo2 to avoid that the user selects the same item for populate the same data in the dgv2. In a brief, the displayed data in two dgv1, dgv2 are different. Any helps in C# code, I really appreciate it. Thanks in advance.


jQuery: Styling DropDownList Alternating Items (Rows)

  
In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

Hide a repeater in ASP.NET C# if the DataSource contains no items?

  
I have an ASP.NET page that uses a repeater nested within another repeater to generate a listing of data. It's to the effect of the following:
In the (C#) code-behind I'm basically using LINQ to pull a listing of information from an XML document and bind that information to the first repeater.

Searching for the answer to this, it seems the method is to determine whether the data for the nested repeater is empty. If it is, then you set the visibility of the repeater to false.

Custom Editing Behavior for DataGridView TextBox Columns

  
For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

AutoCompleteStringCollection for text box in DataGridView 2.0

  
I have been searching for a way to have autocomplete in a DataGridTextBox
object. There does not appear to be an obvious way to do this like you would
for a TextBox outside of a grid using the AutoCompleteCustomSource. Any
thoughts on how I can add this collection? :)

Working with DropDownList and ListBox Controls in ASP.NET

  
"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

ASP.NET DropDownList Web Control, Part 1

  
Anybody with much experience in ASP has written an include file function for populating the contents of a SELECT dropdown list with entries from a database. Some of the more advanced users have even gone so far as to add caching to their function to reduce database hits for these rarely changing menu options. Naturally, these same techniques are going to be used with ASP.NET, but with a new programming object model. ASP.NET provides a web control, the DropDownList, which can be used for the same purposes as our custom built SELECT tag from Classic ASP.

Declaring a DropDownList in ASP .Net

  
A DropDownList is also commonly known as combo box. It can contain multiple data members, but unlike a normal list box the users can choose only one value from this control. Though the functionality of this DropDownList is much like a Single Row Select List Box, a DropDownList can save a lot of GUI space as it is rendered on a Single line and is expanded only when the user clicks on the Control

Multiple Column Dropdownlist for the ASP.NET DataGrid

  
Based on my previous control "Multiple Column DropDownList for ASP.NET", I received many emails asking for the same control to be used in the DataGrid for web applications. Here we go.. This control can be used as the regular MS DropDownList in the DataGrid and also as a regular dropdownlist. It has all the properties, like DataTextField, DataValueField, DataSource, SelectedIndex etc. The download file contains the samples both in VB.NET and C#. In this sample, I have used the Northwind database of SQL Server.

ASP.NET Multiple Selection DropDownList with AJAX HoverMenuExtender

  
Recently, I was looking for a multiple selection dropdownlist control for my new project. After spending some time researching for it, I decided to put together all my finding in one web user control. This web user control consists of an ASP.NET AJAX HoverMenuExtender, JavaScript, StyleSheet and CheckBoxListExCtrl . The final product will work with or without a MasterPage and you can drag and drop more than one instances of the control on to the page.

Manually sorting and paging Gridview without using datasource control

  
Many a times while working with Gridview we want to work with the paging and sorting functionality without using any datasource control. Gridview is flexible enough to perform these tasks without the use of any datasource control and only a few lines of code.

How to bind GridView and DropDownList controls using DataTable object

  
In .net framework 2.0, you can load a DataTable in memory by consuming a data source using a DataReader. In this version you will find the flexibility in accessing the DataReader means write access code once and use again and again using DataReader. To see the functionality of DataTable consider an example that is created using VS2005.

How to bind TemplateField DropDownList with ArrayList?

  

Hi Expert!

  I'm trying gridview templateField DropDownList bind with arraylist. When i set bindsource i got this error. "//Error Object reference not set to an instance of an object."

My Sample .aspx

<asp:TemplateField HeaderText="Type">
                    <FooterTemplate>
                        <asp:DropDownList ID="_grvcboType" runat="server" Width="117px" DataTextField="Display" DataValueField="Value">
                        </asp:DropDownList>
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label7" runat="ser

how to make a dropdownlist looks like google search box

  

dear all...

any idea how to do that ?


Thnx in advance


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