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


Top 5 Contributors of the Month
ASPEvil
david stephan
Santhakumar Munuswamy
Fauzul Azmi
Post New Web Links

Problem Binding DropdownList in a gridView to a datasource

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
 
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!


View Complete Post


More Related Resource Links

Configure Datasource using gridview problem

  

Hi i  have one asp.net textbox control..

and one dropdownlist inside gridview itemtemplate textbox..

what my problem..?

A Textbox36 has values some thing like this A1','A2','A3

i wirte this below query in sqldatasource1 and this sqldarasource1 is binded to gridview ItemTemplate Dropdownlist..

Select ItemName from Table1 where code in (@C)

Here @C im refering to Textbox36..

It show me the record if it has one value if its multiple like A1','A2','A3 it not showing/filtering ItemName data..

Whatz the probel?


GridView column/row data binding problem

  
Hi All, I have a table with the following structure: Attribute------------- AttributeIdWeekNoDayNoAttribute1Attribute2Attribute3Attribute4Attribute5 ........ likewise. I want to display these data in a gridview in the following manner                                  Sunday    Monday Tuesday ............ (till Saturday) - should be gridview columns, I can retrieve this using dayno Attribute 1 Attribute 2 Attribute 3 Attribute 4 .......... like wise attributes should be taken in to rows.Is this possible in a gridview, if so how can I do that?

Problem binding data to DropDownList in DetailsView

  
Hi guys. I have a slight issue I awas trying to fix for 2-3 days, but nothing I try works. The scenario: DetailsView control in edit mode, I pass parameters to the SqlDataSourceProducts (edit.aspx?id=2) and the data source selects the appropriate data and fills in the DetailsView form. Except two drop down lists. These two DDLs (DDL2 and DDL3) are dependent on the previous DDL (DDL1) in the DetailsView. Thanks to PeteNet, when the selected value of the DDL1 changes, DDL2 and 3 change their lists and get bound to the database. The problem is: when I edit something from the database, DDL2 and 3 appear empty and when I update any other field and leave these, they get blanked in the database.  My goal is to set the selected value of DDL2 and 3 to the values in the database WHERE ID = QueryStringField="id". I can go for not binding the data unless the field is changed, but does not sound professional and user friendly. code: The SqlDataSource used to select the parameters from the table and populate the DetailsView <asp:SqlDataSource ID="SqlDataSourceProduct" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT ID, wm_number, upc, check_digit, unit, price_unit, brand, category, shelves, type, cooking, storage, packaging, origin, nutriti

Gridview Dropdownlist databinding problem

  

I am using gridview, in ItemTemplate  I am using dropdownlist which has the hard-coded value, I want to get updated value of dropdownlist from database, but whenever I use EVAL, it throws the following error:


 'ddl' has a SelectedValue which is invalid because it does not exist in the list of items.

Parameter name: value


I am using the following code:

<asp:TemplateField HeaderText="Status"  >
                  <ItemTemplate>
                      <asp:DropDownList ID="ddl" runat="server" SelectedValue='<%# Bind("Status")%>' >
      

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


Problem in binding List<> object to Gridview

  

Dears,

We I bind a list<> object to a gridview it calls an error like this:

Error: DataBinding: 'Default2+JobsList' does not contain a property with the name 'JobId'

Hear is my markup Codes:

<asp:GridView ID="GridView1" runat="server" DataKeyNames="JobId" AutoGenerateColumns="False"
                            OnRowCommand="GridView1_RowCommand">
                            <Columns>
                                <asp:BoundField DataField="JobName" .../>
                                <asp:BoundField DataField="JobExplain" .../>
                                <asp:ButtonField CommandName="DeleteJob" .../>
                            </Columns>
</asp:GridView>


and Code behind:

public struct JobsList
    {
        public int JobId;
        public string JobName, JobExplain;
        public JobsList(int id, string name, string explain)
        {
            JobId = id;
            JobName = name;
            JobExplain = explain;
        }
    }

List<JobsList> list = new List<JobsList>();

....

list.Add(new JobsList(Approperiate Attributes..));
GridView1.DataSource = list;
GridView1.Data

GridView EditItemTemplate DropDownList Problem

  

I'm creating a GridView that displays the details of an order.  One of the columns shows which Location the order went to.  All the information is correctly displayed and is based on a single SQL query (SqlDataSource1). 

When they edit the item, I have another SQL query (SqlDataSource2)  that correctly pulls a list of all the customer's locations and populates a DropDownList.  The issue I'm having is trying to set the SelectedValue of the DropDownList to the Location value, which is pulled in the first SQL query.

Here's what I've been working with so far... 

<asp:TemplateField>
   <ItemTemplate

GridView EditItemTemplate DropDownList Problem

  

I'm creating a GridView that displays the details of an order.  One of the columns shows which Location the order went to.  All the information is correctly displayed and is based on a single SQL query (SqlDataSource1). 

When they edit the item, I have another SQL query (SqlDataSource2)  that correctly pulls a list of all the customer's locations and populates a DropDownList.  The issue I'm having is trying to set the SelectedValue of the DropDownList to the Location value, which is pulled in the first SQL query.

Here's what I've been working with so far... 

<asp:TemplateField>
   <ItemTemplate

Problem with datasource and gridview

  

I have a very simple form that contains an asp:GridView and a PgSqlDataSource (a datasource control for PostgreSQL from DevArt.com) which is part of a web site.

The asp:GridView is defined as follows:

<asp:GridView
                ID="grdClasificacion"
                runat="server"
                AllowPaging="True"
                AutoGenerateColumns="False"
                CellPadding="4"
                CellSpacing="1"
                DataKeyNames="clave"
                DataSourceID="dsClasificacion"
                PageSize="11"
  

Problem in binding special characters in gridview

  

Hi, I am facing problem while binding special characters to gridview. Whenever I try to bindthe characters <? the string truncates from there. eg: if I enter Employee<?1 in the Add employee textbox and save, the Employee list gridview displays only Employee. if I enter  Empl<?oyee1 the result is Empl
The database saves the correct value. Only while displaying in the gridview this problem occurs.
Any pointers to this?
The code to bind gridview is:
  <asp:TemplateField HeaderText="Employee Name">
   <ItemTemplate>

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

  
Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Problem to group radio button across gridview rows

  
In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

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.

Gridview Enable Selection Problem

  

Hi,


I have a gridview with Enable selection and Enable Paging equals to TRUE.

I also set the PageSize of my gridview to 4 so that I only displays 4 rows per page.

The problem is when I click the pager in the bottom of my gridview, my gridview is disappearing and no records appear.


Here is code behind of my gridview:

If e.Row.RowType = DataControlRowType.DataRow Then
                e.Row.Attributes("style") = "cursor:pointer"

                e.Row.Cells(2).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(3).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(4).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(5).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(6).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
   

styling dropdownlist problem

  

Dear All,

im facing a problem while styling my ddl, what i did is:

<div><asp ropDownList ID="DropDownList1" runat="server" style="background-color:Transparent;" Width="100%">
    </asp: dropDownList></div>

<div class="stlGradient">
<asp ropDownList ID="DropDownList1" runat="server" style="background-color:Transparent;border:none;" Width="100%"></asp: dropDownList>
</div>

the DIV style is having a bg image repeated X.

now this worked on Firefox
on google Chrome: the border gone but the background still white
on IE 7: nothing happend

thanks for helping.


Binding GridView with SqlDataSource at runtime?

  

Hi, I want to create a generic page which contains a gridview and sqldatasource. I want to put these two controls on .aspx (C#) page but bind them at runtime. It should have selectcommand, updatecommand, deletecommand and insertcommand. Stored procedures are created for that. Help is needed to make it. Please post some link or code. Regards, ap.


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