Forms Data Controls :: How To Display The Data Based On Dropdownlist Value In Gridview

Dec 30, 2010

I have a gridview.In Header of gridview i added dropdownlist.


Here the problem is, i am getting selected value in temp variable(if i change to 20,50,100) in dropdown selection event but it is not binding the pagesize for the gridview and also dropdownlist showing the value "10" only after the pageload.

View 6 Replies

Similar Messages:

Data Controls :: Get Data Based On DropDownList Selection And Display In TextBox?

Feb 19, 2014

i have a question, i ywant to know how to make if i pick an item from a drop down list it description goes to a textbox beside it automaticaly is very very important to me at this point

View 1 Replies

Forms Data Controls :: Filter Gridview Based On Value From Dropdownlist?

Aug 9, 2010

I have a gridview that I'd like to have changed based on a value selected in a dropdownlist. I'm able to get the aspx page to display the dropdown list (comming from SQL), and when I select a value, the page reloads, but no data show in the griview.


Here is the aspx page:


View 8 Replies

Forms Data Controls :: How To Display The Images In GridView Based On Certain Condition

Jun 29, 2010

if i give the 10 number,10 number of same images should be diplayd in the Grid View.

how can i do that.

View 7 Replies

Forms Data Controls :: Image Display In Gridview Based On Condition?

Mar 7, 2011

i m displaying an image in gridview based on condition from sql table. That is if the colum named "availabillity" is A the image will be red n if the value is "NA" the image will be green. i am using RowDataBound event.

but i am getting error as "Cannot implicitly convert type 'System.Web.UI.WebControls.DataControlRowType' to 'bool'".

View 7 Replies

Forms Data Controls :: Dynamic Gridview With Dropdownlist / Dynamically Set The List Values Based On Parameters (of The Row They Are On)

May 28, 2010

I'm new to web dev and c# so please bare with me. I am trying to create a dynamic gridview in a web form for users to to answer questions with (code below).

The dificulty im having is that i am nesting a dropdwonlist in the gridview and want to be able to dynamically set the list values based on parameters (of the row they are on). These values are in the main dataset for the gridview as each row represents a questionid and question text and then a ddl for the criteria...

I just don't know how to set the values for the dropdown all the code so far is below... just need to be able to populate the dropdowns with the relevant values.

I have created a stored proc to return the different criteria based on the questionid and questionGroupid which is the dataset that populates the other fields in the gridview: dbo.usp_QuestionCriteria @QuestionGroupId, @QuestionId

I have added this as a tableadapter called criteriaTableAdapter in a xsd file as well using the wizard... not sure if this is the right option though or just use the same method as i have for the other stored procedure as in the code below:


]using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Sql"].ConnectionString);
SqlCommand com = new SqlCommand("usp_QuestionGroupDS", con);
com.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ada = new SqlDataAdapter(com);
DataSet ds = new DataSet();
for (int i = 0; i < ds.Tables.Count; i++)
if (ds.Tables[i].Rows.Count > 0)
GridView gvDynamicQuestion = new GridView();
gvDynamicQuestion.Width = Unit.Pixel(700);
gvDynamicQuestion.BorderWidth = Unit.Pixel(0);
gvDynamicQuestion.Caption = "<div id="nifty" class="QuestionGroup"> <b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>" + ds.Tables[i].Rows[0]["Category"].ToString() + " Questions<b class="rbottom"><b
class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b></div>";
gvDynamicQuestion.AutoGenerateColumns = false;
gvDynamicQuestion.ShowFooter = true;
TemplateField tf = null;
tf = new TemplateField();
tf.HeaderTemplate = new DynamicGridViewTextTemplate("QuestionId", DataControlRowType.Header);
tf.ItemTemplate = new DynamicGridViewTextTemplate("QuestionId", DataControlRowType.DataRow);
tf.FooterTemplate = new DynamicGridViewTextTemplate(DataControlRowType.Footer, ds.Tables[i].Rows.Count);
tf = new TemplateField();
tf.HeaderTemplate = new DynamicGridViewTextTemplate("Question", DataControlRowType.Header);
tf.ItemTemplate = new DynamicGridViewTextTemplate("Question", DataControlRowType.DataRow);
tf = new TemplateField();
tf.HeaderText = "Criteria";
tf.HeaderTemplate = new DynamicGridViewTextTemplate("Criteria", DataControlRowType.Header);
tf.ItemTemplate = new DynamicGridViewDDLTemplate();
////tf = new TemplateField();
////tf.HeaderText = "Criteria";
////tf.ItemTemplate = new DynamicGridViewDDLTemplate();
gvDynamicQuestion.DataSource = ds.Tables[i];
protected void DynamicGrid_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.Footer)
public class DynamicGridViewTextTemplate : ITemplate
string _ColName;
DataControlRowType _rowType;
int _Count;
public DynamicGridViewTextTemplate(string ColName, DataControlRowType RowType)
_ColName = ColName;
_rowType = RowType;
public DynamicGridViewTextTemplate(DataControlRowType RowType, int QuestionCount)
_rowType = RowType;
_Count = QuestionCount;
public void InstantiateIn(System.Web.UI.Control container)
switch (_rowType)
case DataControlRowType.Header:
Literal lc = new Literal();
lc.Text = "<b>" + _ColName + "</b>";
case DataControlRowType.DataRow:
Label lbl = new Label();
lbl.DataBinding += new EventHandler(this.lbl_DataBind);
case DataControlRowType.Footer:
Literal flc = new Literal();
flc.Text = "<b>Total No of Questions:" + _Count + "</b>";
private void lbl_DataBind(Object sender, EventArgs e)
Label lbl = (Label)sender;
GridViewRow row = (GridViewRow)lbl.NamingContainer;
lbl.Text =DataBinder.Eval(row.DataItem, _ColName).ToString();
public class DynamicGridViewDDLTemplate : ITemplate
// Implementation of ITemplate
public void InstantiateIn(System.Web.UI.Control container)
// Create a DDL
DropDownList ddl = new DropDownList();
//Attach method to delegate
ddl.DataBinding += new System.EventHandler(this.ddl_DataBind);
//Method that responds to the DataBinding event
private void ddl_DataBind(object sender, System.EventArgs e)
//DropDownList ddl = (DropDownList)sender;
//DataGridItem container = (DataGridItem)ddl.NamingContainer;
//ddl.Data.Checked = [Data binding expression];


View 7 Replies

Forms Data Controls :: Display Gridview Based On Dropdown List Selection?

Feb 21, 2010

I'm having trouble figuring out how to display a gridview based on the selection of a drop down list. I manually entered the drop down list items, but in the configure/choose data source I don't understand how you make a relationship between each list item and the corresponding database table you want to show.

View 7 Replies

Data Controls :: Display Data In GridView Based On Two Tables

Nov 28, 2012

I have two tables Emp,Dept

EMP                          DEPT

EmpNo(PKEY) Id(FKEY) to Empno
Fname Location
Lname Date

I want to display Gridview columns like this ....

E.Fname,E.Lname, based on Id
Display E.Fname,E.Lnamebased ob Id

View 1 Replies

Forms Data Controls :: Gridview-Calculate Value Based On Formula That Varies Dependent On Selected Code In Dropdownlist?

Jul 2, 2010

GridViewDetails uses templatefields. In edittemplate I put a button called "ButtonUpdateAdjustAmount" with OnClick="Update_AdjustAmount" in the EditItemTemplate for the "Amt to be Adj" column. There is also a textbox. My user's should be able to edit the textbox, but I also want the ability to click the button and the textbox populated with the correct calculated value. The formula varies based on the "code" column which is a dropdownlist called "DropListCode".

I am fairly new to, vb, forgive my code writing. Eventually I need to also put the same functionality on the insertrow for my gridview. But first wanted to get the edit one working. I am using templatefields for all columns and the FooterTemplate to perform the Insert New Detail Line.

I can get the functionality to work for the first data row and only if I take out the If code.SelectedValue = ... line and leave 1 static formula. However that isn't going to work. If DropListCode.SelectedValue is DNR then AdjAmt should be ((q_ordered - q_received) * cost). If DropListCode. SelectedValue is OV then AdjAmt should be (RKNumber * cost). If DropListCode.SelectedValue is NB the AdjAmt should be ((q_received - q_ordered) * cost). If DropListCode.SelectedValue is DAM then AdjAmt should be (RKNumber * cost)

Code behind for the OnClick:


.aspx page - GridViewDetails programming:


View 6 Replies

Data Controls :: Delete Row In GridView Based On DropDownList Selection

Nov 18, 2013

To what extent our institution is useful for you  Dropdownlist1(Good/Poor).When user select the Poor form the Dropdownlist1 in that case  ONLY POPUP screen will be displayed.The POPUP Screen as follows

            Textbox (In that textbox user type the reason for Poor)

When user Click the Submit (Button) the selected dropdownlist and Remarks will be displayed in the Gridview. The Gridview as follows

              Dropdown           Reason
                 0                       The institution has to be improved for lot

instead of Select the Good from dropdownlist1, user wrongly select the Poor from the dropdownlist. that time POPUP screen is to displayed.(Only when user select the Poor from the Dropdownlist POUP Screen is to be displayed in that textbox type the reason and click the Submit Button).  Then Gridview as follows

              Dropdown           Reason
                 0                       The institution has to be improved for lot

Then user again select the Good from the Dopdownlist1 means Previously value in the Gridview.Dropdown and reason has to be deleted in the Gridview.for that how can i do using csharp.

View 1 Replies

Data Controls :: Filter GridView Based On Year In DropDownList

Dec 23, 2015

How to create reporting screen and show it either into gridview or list view?

See below as my report criteria:

Step 1. User will choose either want to display by Depatment or Year?

Step 2. Press Select Button

Step 3. Data will show as per user request.

View 1 Replies

Data Controls :: Populate GridView Based On DropDownList Selection

May 7, 2015

If the drop down list event change gridview column values to be changed.

View 1 Replies

Data Controls :: GridView - Set SelectedValue Of One DropDownList Based On Other Using JavaScript

May 7, 2015

I have two dropdownlists ddl1 & ddl2, both of which are inside a GridView.

How do I change the index of second dropdownlist (ddl2) according to the selected index of the first dropdownlist (ddl) using JavaScript...

View 1 Replies

Forms Data Controls :: Display Some Xml Tags In Gridview Dynamically Based On User Selection?

Jul 17, 2010

i have displayed a xml file in the tree view form by binding i want a sample code to access the nodes which are being selected and to display dynamically in a grid view

View 4 Replies

Forms Data Controls :: Gridview: Filter Display Results Based On What Roll A User Belongs

Oct 20, 2010

I have enabled User Rolls and assigned several Roll names such as 10, 11, 12, etc. I have a SQL Table that contains various fields of information including one named AuthorizedUserRoll, it's nchar(2).

A logged in user should only see the records in Gridview that matches his/her roll.

I'm using Web Forms and VB.

View 1 Replies

Data Controls :: Conditionally Update Value Of GridView Row Based On DropDownList Selection

Mar 11, 2014

How to update each data in gridview from template field textbox?

if select reason is adjust-In then update plus the qty else adjust -Out minus the qty. 

<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3A64F2" HeaderStyle-ForeColor="White" runat="server" AutoGenerateColumns="false">
<asp:BoundField DataField= "RowNumber" HeaderText="RowNumber" />
<asp:BoundField DataField= "INV_ID" HeaderText="INV_ID" ItemStyle-Width="150" />
<asp:BoundField DataField= "INV_TYPE" HeaderText="INV_TYPE" ItemStyle-Width="150" />
<asp:BoundField DataField= "INV_SHORTDESC" HeaderText="INV_SHORTDESC" ItemStyle-Width="150" />
<asp:BoundField DataField= "INV_LOCATION" HeaderText="INV_LOCATION" ItemStyle-Width="150" />
<asp:BoundField DataField= "INV_QTY" HeaderText="INV_QTY" ItemStyle-Width="100" />


View 1 Replies

Forms Data Controls :: Dropdownlist Won't Display Values In Gridview With Use Of Parameter

Jan 31, 2010

My database has 4 colums;


Singles and suppers are money fields for the price of same item. A bit like the price of a Small, Medium or Large item. What I would like to do is display the 'Singles' price and 'Suppers' price in seperate listitems so the user can choose 1 of them.

Traditional Name__________Size

Price of Single is: 1.50
Price of Supper is: 2.50

My page loads up with the correct items in TraditionalName colum but the DropDownList is completely empty. I'm aware I don't have anything in for DataValueField and DataTextField but I have tried putting things in these attributes, like Suppers and Singles, but nothing works, so I have taken them out below.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="TraditionalID" DataSourceID="SqlDataSource1">
<asp:BoundField DataField="TraditionalID" HeaderText="TraditionalID" InsertVisible="False" ReadOnly="True" SortExpression="TraditionalID" Visible="False" />
<asp:BoundField DataField="TraditionalName" HeaderText="Meal" SortExpression="TraditionalName" />
<asp:templateField HeaderText="Size">
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2">
<asp:HiddenField ID="RowTraditionalName" runat="server" Visible="false" Value='<%# Eval("TraditionalName") %>' />
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:The CodfatherConnectionString %>"
SelectCommand="SELECT Suppers AS Suppers, Singles AS Singles FROM [Traditional] WHERE TraditionalName = @TraditionalName">
ControlParameter Name="TraditionalName" Type="String" ControlID="RowTraditionalName" PropertyName="Value" />

View 1 Replies

DataSource Controls :: GridView To Display The Data Based On One Or The Other?

Apr 5, 2010

I have a web form with two drop downs.I want the gridView to display the data based on one or the other.The user can then select a record to be displayed in a detail view.This method works as long as I am only viewing the data.If the user edits the data in the detail View and then updates the detail view when the page reloads the grid goes blank.I have traced the code and there is data in the query after the update but the select statement for the LinqDataSource is overriding the code in the lqGrid_Selecting.I can make the above scenario work using SqlDataSources,but I thought LinqDataSources were the way of the future.


View 1 Replies

Data Controls :: How To Display Gridview Based Only Particular Name From One Table

Aug 24, 2013

How can I display my table (one sql table)say i have 10 list of products in "houseware" category and the other 10 list is "food" category..

so i have 20 list in my table but only want to show only one category at one time using dropdownlist to activate one category at a time. also i want to display them using multiview component available in toolbox.. i'm using c# language..

View 1 Replies

Data Controls :: Disable Or Hide DropDownList Control Based On Condition In GridView

Dec 18, 2013

I am using a dropdownlist in a gridview which contains 3 valuesappleorangebanana

apple will be displayed as default valueif i select orange and banana the dropdownlist list should be disable or hidden but the selected value must be displayed

protected void btnsubmit_Click(object sender, EventArgs e)
foreach (GridViewRow gr in GridView1.Rows)


View 1 Replies

Data Controls :: Show / Hide TextBox Based On Value Of DropDownList Inside GridView?

May 7, 2015

This is my Code

My query is if i select Other in dropdownlist i want visible textbox..

how to i do it..

<asp:GridView ID="TypeFruit" runat="server">
<asp:TemplateField HeaderText="Type" >
<asp:DropDownList ID="ddlfruit" runat="server" >
<asp:ListItem Value="0">Select</asp:ListItem>
<asp:ListItem Value="1">Fruit</asp:ListItem>
<asp:ListItem Value="2">Other</asp:ListItem>
<asp:TextBox ID="TxtOther" runat="server" Visible="false"></asp:TextBox>

View 1 Replies

Data Controls :: Enable Disable DropDownList Inside GridView Based On CheckBox

Feb 19, 2014

How to enable & disable data value from selected table ?

For Example,  select ID from employeeTlb(for Dropdownlist function) then in asp:checkbox able to tick enable & disable that control  the  data in dropdownlist show/ hide ?

View 1 Replies

Data Controls :: How To Display Data In GridView Selected By DropDownList

May 7, 2015

My code but its not give expected output

protected void Page_Load(object sender, EventArgs e)

[Code] ....

View 1 Replies

Forms Data Controls :: Dropdownlist With Request.QueryString - Display Gridview In Next Page

Jan 4, 2011


in my page am having one dropdownlist,Textbox and Search Button.Dropdownlist consists of Problem id,Phone No,Email,CardNo. when i select any of the above and enters a related string in textbox and click on search button a gridview will appear with related details. Everything is fine. but my challange is to display this gridview in next page.. how itz possible. i think request.Querystring helps me.but i dnt know how to write dis.Here am Pasting my code. Aspx.cs


Aspx code:


View 11 Replies

Data Controls :: How To Display Different Row Colors Based On Condition In Gridview

Jul 19, 2013

how to display row values based on condition in grid view control and how to display different row colors based on condition in grid view.

View 1 Replies

Copyrights 2005-15, All rights reserved