DataSource Controls :: What Is Best Way To Lookup A Value Based On Two Other Values

May 15, 2010

I have a database table with three columns of interest

slottypekey (integer)

taskkey (integer)

permission (string)

Lets's say I have a stored procedure that gets this data and puts it into a dataset.

I would like to write a function that has input parameters of slottypekey and taskkey

and that returns the associated permission. What is the best way to do this?

View 4 Replies


Similar Messages:

DataSource Controls :: Using Lookup Value In Gridview?

Sep 15, 2010

I've been struggling all day trying to make this work, but I'm just not having any luck. I have 2 tables, 1 is a lookup table and the other is a user table. The lookup table stores the State values in text form, where the user table stores the ID of the State for the particular user. I'm trying to create a editable grid view that allows the user to update their State based on values in the lookup table. I've created an Edit Template with a drop down for the State field. When the user clicks on "Edit" in the GridView I need to be able to reference the SelectedValue of the State and write the index of the State to my user profile table. I'm using two different data sources for this since the GridView needs to display each record from the users table and the Edit Template needs to display only values from the Lookup table. I've included my code below.

<%@ Page Language="C#" MasterPageFile="~/JFCS.Master" CodeBehind="modifyFunder.aspx.cs" Inherits="jfcsGRAMS.modifyFunder" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
<div style="float:left;height:500px;width:100%">[code].....

View 4 Replies

DataSource Controls :: Case Statement Assign Values Based On Condition?

Feb 2, 2010

I need to modify the results (NULL) to reflect '0.00'.

My query statement is giving me an error at the CASE level.

[code]...

View 3 Replies

DataSource Controls :: How To Fetch Rows Based On Values In A Session Variable

Dec 23, 2010

How to Fetch Rows based on Values in a Session Variable

View 4 Replies

Forms Data Controls :: How To Add Lookup Table Values To A DropDownList And Bind To A FKValue In The Grid

Jan 26, 2011

I have a GridView control that has a SQLDataSource.

The GridView provides me with a list of musical artists (from the tblArtists)

In the Grid, I have a field, FKGenreID, that is a Foreign Key value for music Genres.

(An example of the data in that field would be "7", which upon lookup would mean Classical in the
tblGenreList table.)

What I'd like to do is add a DropDownList control that looks up the tblGenreList table and populates the DropDownList with the ID and Description from the tblGenreList Lookup table.

Now the tricky part is that if the GridView field (FKGenreID) has a value, then I'd like the corresponding Genre Description to be displayed in the DropDownList

Alternately, if there is no value for FKGenreID in the GridView, then I'd like the DropDownList to show that nothing was selected, but have the list of Genres available.

Most importantly here, when the user makes a selection, I'd like the GenreID (from the DropDownList) to be entered into the FKGenreID field in the GridView field.

My thought is that a gridview record may or may not have a value in the FKGenreID field. Either way, the DropDownList is bound to that field. The DropDownList would display a list ofGenre Descriptions for the user to select from. Upon selection, the GenreID column of the DropDownList becomes the value in for the FKGenreID field in the GridView.

Is this possible?

In case it matters, I'm using ASP.NET 4, Visual Studio 2010, and coding in VB

View 1 Replies

MVC :: Lookup Customer Information Based On ID?

Mar 2, 2011

This form has some information for making a reservation for a customer at a dining venue. If the customer is a "known" / "returning" customer id like to fill the form based on the customer ID. Some of the things on the form are ...

textbox=CustomerID
Input Button
textbox=FirstName
textbox=Lastnemt

Using MVC, What would be the best way to go about going back to the server to find the customers first / last name and posting it back to the values in the textboxes ? Ive been trying to work with AJAX & JQuery but i cant seem to update the values in the textbox using AJAX.

View 2 Replies

Forms Data Controls :: DetailsView Insert Mode - Field "manager Name" To Be Populated Based On A Lookup Table In The Database

Aug 30, 2010

On my DetailsView for inserting, I have a field "manager code". When the user types in the code, I want another field "manager name" to be populated based on a lookup table in the database. I have done this on a FormView using code behind and "ontextchanged". How can I do this in DetailsView?

View 3 Replies

DataSource Controls :: Doing A Data Base Lookup - Where Is The Nvarchar Size Of 4000 Coming From

Feb 18, 2011

I want to grab some values with a form and then do a lookup via a datareader in a data access class (N-Tier).

I want to return a data list and bind that to a form view control.

Here is some code from the DAL, Business object and search form.

The parameterized query doesn't like the data being passed to it from my web page .

[code]....

[Code]....

Where is the nvarchar size of 4000 coming from ?

View 9 Replies

DataSource Controls :: Lookup Type Command To Select A Single Value From An Sqlserver Table?

Apr 10, 2010

I'm using vwd 2008 express

I need to display a single field from an sqlserver table, do I need to use sqlDataSource ect. or is there a simpler way (like msaccess's LookUp) for single values.

View 1 Replies

Forms Data Controls :: Create A Lookup Data Source Based On A Union Query With The Actual Data And A Blank Record?

Jun 1, 2010

I'm new to ASP.net 3.5 and trying to create a test site so I can figure out how to use it in the real world. I have created a FormView (Formview1) based on a Client table using Linq Data Sources. The page includes a DropDownList to lookup Clients. I have added a list option (<asp:ListOption value="" Text="(Select Client)" and set AppendDataBoundItems=true so my added option is displayed. I decided to try to use Formview with only the Edit and Insert Modes, and I have set the Default Mode = Insert. When you open the page, a blank Client record is displayed.

The Client record contains serveral lookup fields and they have drop down lists for each. When I select a client from the Client DropDownList, is get the following message 'ddlClientType' has a SelectedValue which is invalid because it does not exist in the list of items I had this problem before and decided the best way to handle this (in the interim) was to turn off foreign key constraints for each of the lookup fields (e.g. ClientType) in SQL Server. That worked for 2-3 days. Now the problem has started again.

When I develop in other applications, I would simply create a lookup data source based on a Union Query with the actual data and a blank record. How can you do this using Linq DataSources. Can you get access and modify the queries?

View 1 Replies

Web Forms :: LookUp Windows Returned Values

Oct 20, 2010

In a webform, I have a formview with respective InsertItemTemplate. I have 2 Look Up buttons, one for Student which opens Student LookUp, and one for Mentor which opens the Mentor Look Up.

First on the input screen sequence is allowing the user to choose Student first. User clicks the Student LookUp button, The StudentLookUp Window is shown, user selects a student, the selected student information is returned and displayed on the calling screen.

The user then clicks on the Mentor LookUp button. The Mentor LookUp window is shown. As this is happening, the values for the Student information, which I have populated upon selecting a student from the Student LookUp goes blank. Can anyone tell me why?

[code]....

View 2 Replies

N Tier - How Should Lookup Values Be Represented In Business Objects

Mar 25, 2011

I'm currently writing an N-Tier architected ASP.NET system with a relatively normalised SQL database backend, but I'm struggling to get my head around how lookup values should be represented in my business objects (I don't get the priviledge of using EF or ORMs). My table (as an example) could be structured like this:

CoreDataTable:

ID | Name | Favourite_Colour
---|-------|-----------------
01 | Peter | 01
02 | John | 03
03 | Mary | 05

ColoursLookup:

ID | Colour | is_active
---|--------|----------
01 | Red | 1
02 | Green | 1
03 | Blue | 1
04 | Pink | 1
05 | Black | 1

Now initially, I had created my business object to look like this:

[code]....

I'm 100% convinced that I'm (a) overthinking this, and (b) making it more complicated than it needs to be. So, is there a preferred way of doing this? Or is there an option that I've overlooked?

View 2 Replies

Data Controls :: Change Color Of DropDownList Based On Values

Apr 27, 2016

How can change the color of dropdownlist with based on their Text 

If  dropdownlist have  listitem Santosh  and Arati if santosh color is  red if Arati color is blue when page is loading

View 1 Replies

Web Forms :: Dynamic Controls Creation / Rendering Based On Postback Values

Nov 8, 2010

I had successfully created a functionality where I can dynamically add rows and columns to a asp table by creating/re-creating controls on every page load.

I have 2 buttons - Add rows and Add columns that, basically according to a asp.,net page life cycle, occur in the following order and work perfectly fine.

Page load is fired and controls along with their viewstate are recreated. In Add row button click event - I just create a new table row and add controls to each cell dynamically.

Same thing with Add column, Delete Row and Delete Column button click events.

However, now I added a Dropdown which when its index is changed needs to retrieve values from the database and create controls based on those values and then also bind the Db values.

But it doesn't work correctly since the asp.net page cycle cannot capture the dropdown's selected value in page_load as the page_load fired first and then the selectedindexchanged event is fired later, the controls are not created.

I don't know how to handle this scenario and incorporate it into my existing code.

View 3 Replies

Forms Data Controls :: Updating The Datasource / Mark All The Values In The Binding Column Of Datasource If Checkbox In Headertemplate Is Checked?

Sep 29, 2010

Scenario:
I am creating a custom gridview control which has a custom CheckBoxTemplateField column (deriving from TemplateField class). This template field column has custom Checkboxheadertemplate (implementing ITemplate) and CheckboxItemTemplate (also implementing ITemplate). In InstantiateIn method of both templates (header as well as Item template), I am adding a checkbox control which has Autopostback = true.

My requirement is:
I want to mark all the values in the binding column of datasource if checkbox in headertemplate is checked. I dont want to mark only rows visible on grid. I WANT TO MARK ALL ROWS IN DATASOURCE. I want to do this in _CheckedChanged event of checkbox in header template.

Problem I am facing: When I check/uncheck the checkbox in header, it postbacks. so in OnCheckedChanged event, gridview's datasource is null. Secondly, in any event of gridview, I could access only those rows of datasource for which corresponding rows are visible in gridview through Gridviewrow.DataItem property. But I want to set it for all rows in datasource.

View 5 Replies

Forms Data Controls :: Assigning Colour To List Items Based On Their Values?

Feb 9, 2010

Is it possible to assign a colour to a drop down list item based on it's value?For example: I have a drop downlist where I've got a bunch of items that have integer

values. I would like to highlight the items with values in 1000s in grey.

Here is what the list looks like:

list_item_name list_item_value
HEADING1 1000
HEADING2 1000
HEADING3 1000
item1 1
HEADING4 1000
item4 4
item5 5
HEADING5 1000
HEADING1 2000
HEADING2 2000
item2 2
item3 3
HEADING3 2000
HEADING4 2000
HEADING5 2000

I've boldified the items I'd like to be highlighted in grey ,For added complexity I need to highlight the items with values 1000 in a light shade of gray and items with values 2000 in a darker shade of grey. I'm using Web Developer, and C#

View 4 Replies

Forms Data Controls :: GridView Conditional Formatting Based On Duplicate Values?

Jun 2, 2010

I have a gridview containing serial-numbers.

I would like to format the background each data-row that contains a duplicate serial-number value.

I'm planning to do this using a DataBound event handler.

So, in English:

Set background colour of THIS_ROW to red where the Serial_Number of THIS_ROW is the same as the Serial_Number of ANY_OTHER_ROW.

All rows with duplicate serial-numbers would be red.

I'm not sure how to write the code for this event.

The gridview is bound to a SQL datasource. Getting the dupes in SQL is easy:

SELECT Serial
FROM Table
GROUP BY Serial
HAVING (COUNT(Serial) > 1)

View 8 Replies

User Controls :: Enable Disable DropDownList Items Based On Database Values

Mar 20, 2014

May i know how to create the control function in asp.net  to control the values ?

Based on the DB table, it active is Y then enable values  in dropdownlist , if N then disable the values. 

View 1 Replies

Forms Data Controls :: Checkbox Selection Based On Group Column Values In Gridview?

Jul 28, 2010

I have to select checkboxes besed on group column values. If you see below gridview, column 3 (GroupN) has 1,1,1,1,2,2,2,2....etc (this column data is not static, will change based on page index. i.e PageIndex =2 may starts with 7,7,7,8,8,8,8,8,9,9,9 etc).

Now My question is.

1). If user selected '1', we have to store value and user must and should select another '1' (atleast two times).

2) If user selected '1', and user trying select '2'. Giving error says "Must have select one then one record in group to combine' (will not allow) and unselect '2'.

3) If user selected '1' atleast two times, and user trying select '2'. Will allow.

4) If user selected '1' atleast two times and selected '2' one time, trying to select '3'. will not allow user to select '3'.

View 3 Replies

Forms Data Controls ::lookup Causes Constraint Error?

Mar 27, 2010

I have a Dataset defined called Content. There is an adapter / table definition in it called Users tied to a table called Users. This table consists of:

[code]...

View 1 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:

[CODE

]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);
con.Open();
SqlCommand com = new SqlCommand("usp_QuestionGroupDS", con);
com.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ada = new SqlDataAdapter(com);
DataSet ds = new DataSet();
ada.Fill(ds);
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);
gvDynamicQuestion.Columns.Add(tf);
tf = new TemplateField();
tf.HeaderTemplate = new DynamicGridViewTextTemplate("Question", DataControlRowType.Header);
tf.ItemTemplate = new DynamicGridViewTextTemplate("Question", DataControlRowType.DataRow);
gvDynamicQuestion.Columns.Add(tf);
tf = new TemplateField();
tf.HeaderText = "Criteria";
tf.HeaderTemplate = new DynamicGridViewTextTemplate("Criteria", DataControlRowType.Header);
tf.ItemTemplate = new DynamicGridViewDDLTemplate();
gvDynamicQuestion.Columns.Add(tf);
////tf = new TemplateField();
////tf.HeaderText = "Criteria";
////tf.ItemTemplate = new DynamicGridViewDDLTemplate();
////gvDynamicQuestion.Columns.Add(tf);
gvDynamicQuestion.DataSource = ds.Tables[i];
gvDynamicQuestion.DataBind();
phDynamicGridHolder.Controls.Add(gvDynamicQuestion);
}
}
}
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>";
container.Controls.Add(lc);
break;
case DataControlRowType.DataRow:
Label lbl = new Label();
lbl.DataBinding += new EventHandler(this.lbl_DataBind);
container.Controls.Add(lbl);
break;
case DataControlRowType.Footer:
Literal flc = new Literal();
flc.Text = "<b>Total No of Questions:" + _Count + "</b>";
container.Controls.Add(flc);
break;
default:
break;
}
}
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);
container.Controls.Add(ddl);
}
//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];
}
}

[/CODE]

View 7 Replies

DataSource Controls :: Build Output Based On Data

May 24, 2010

This is my Table Structure....

OrderNo Itemcode Name AQty BQty

AB1 001 A 50 60
AB1 002 B 50 50
AB1 003 C 50 40
AB1 004 D 100 120
AB1 005 E 100 100
AB1 006 F 100 80
AB2 007 B 100 95

I need The first resultset/Output like This....

OrderNo Itemcode Name AQty BQty Total

AB1 001 A 50 60 -10
AB1 004 D 100 120 -20

I need The Second resultset/Output like This....

OrderNo Itemcode Name AQty BQty Total
AB1 003 C 50 40 10
AB1 006 F 100 80 20
AB2 007 B 100 95 05

I dont need To show 002,005 coz itz Total is zero(0). Herr i need to show Record Based on OrderNo...

View 4 Replies

DataSource Controls :: Linqtosql Contains Based Off Words In Textbox

Mar 22, 2010

I am probably doing this wrong but I want to take all words entered in to a text box and return all records that contain any or all of the words. Can any one point me in the right direction?

protected void ldsGvFaqs_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
if (txbSearch.Text.Length > 0)
{
string temp = string.Empty;
string[] words = txbSearch.Text.Split(' ');
int counter = words.Length;
foreach (var word in words)
{
temp += "Tags.Contains('" + word + "')";
counter -= 1;
if (counter > 0)
{
temp += " || ";
}
}
ldsGvFaqs.Where = temp;
}
}

But I get the following error, Character literal must contain exactly one character.

View 2 Replies

DataSource Controls :: How To Merge Two Table Based On SQL Query

Jun 7, 2010

This is my table stucture...

This is first table...

ItemNo refno Process Name Qty
001 1 A John 50
001 2 A Jon 150
002 3 B
Kalis 100
003 4 A
Bob 300
Second Table
ItemNo Newrefno Process Name Qty
001 001 ZZ peter 50
001 001/a ZkZ Joe 70
002 002 Ab Ray 100
Result Set
001 A John 200 001/a ZZ ZkZ peter joe 50 70
002 B
Kalis 100 002 Ab Null Ray Null 100 Null
003 A
Bob 300 null null null null null null null

Here first row of the result set explanation:

up to this 001 A John 200 based on first table sum...

and 001/a zz ZkZ peter joe 50 70

here 001/a newrefno of 001 so i need to show all the ItemNo 001 record in one row like the above resultset.

View 4 Replies

DataSource Controls :: Adding An Id Field Based On Other Fields

May 16, 2010

ive a DB in access with a single table and no primary key, actually i dont need a primary key but i can consider a date field plus another to make an index. however i want to add a counter field based on every change of date field, for instance ill have many records of 20/May and all must have the same id then when the date is different, the next group of records with that new date must show 2 etc.. is it a quick way to update my database?

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved