Checking if selected field contain value

I am selecting some contetnt from database and than display it into database. Something like that:

OleDbConnection objConn = new OleDbConnection(ConfigurationSettings.AppSettings["DSN"]);
OleDbCommand objCmd;
OleDbDataReader objRdr;

objCmd = new OleDbCommand("SELECT * FROM test'", objConn);
objRdr = objCmd.ExecuteReader();
dg.DataSource = objRdr;

Now I want to check if value of cell is something than display predefinited value in data grid. Sometingh like that:

if  (objRdr["Name"]  == "Joe"){
objRdr["Name"]  = "Welcome Joe";
display value from database
(I know this is wrong, but I need something like that)


7/30/2005 8:12:03 PM 72751 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 15

How are you declaring the datagrid - specifically the AutoGenerateColumns property.  If this property is set to false and you are using templates then, below is one solution.

<asp:Label runat="server" text='<%# CheckName(DataBinder.Eval(Container.DataItem, "Name")) %>' />

In the code-behind

public function CheckName(byval name string) as string
        if name.toLower() = "joe" then
                return "welcome joe"
                 return name
        end if
end function
7/31/2005 7:14:13 AM
Here is my code:

                                <asp:TemplateColumn HeaderText="Units On Order">
                                    <HeaderStyle horizontalalign="Center"></HeaderStyle>
                                    <ItemStyle horizontalalign="Center"></ItemStyle>
                                    <ItemTemplate><%# Check(DataBinder.Eval(Container.DataItem, "Test")) %></ItemTemplate>

protected string Check(object Test)
     if(Test.intValue() == 0)
          return "Out Of Stock";
          return Test.toString();

I get error: 'object' does not contain a definition for 'intValue'

What am I doing wrong??

7/31/2005 10:33:58 AM
Its because the intValue property does not exist. Change the function to this:

protected string Check(object Test)
     if(Convert.ToInt32(Test) == 0)
          return "Out Of Stock";
          return Test.toString();

Sonu Kapoor [MVP]
Feel free to ask me any .NET question | Ajax Data Controls Forum
7/31/2005 2:55:34 PM

Similar Artilces:

problem with selected text field and selected value field in check box list
Hi! i have a  problem with check box list:here is the code for binding the check box list with sqldatasource  SqlDataSource1.SelectCommand = "select vcentrolno,inttpaperno from tabmarksdetails where vcbunchno='" & strBunchNo & "'"  chkEnrolNos.DataBind()say now my chkEnrolNos consist of data in this way:vcentrolno        inttpaperno selected text   selected valueA11439            1A11439            2AR439    ...

Selecting value in one field then causes value in another field to be selected.
I have a web form which contains a date field, the date is populated using a DatePicker which is Javascript based. The form also has a drop down box containing 3 values. What I want to do is when a date has been selected that this will cause the dropdown list value to change to dated which is one of its 3 values. i.e. when the date field is not blank then the value will be selected in the dropdown. What I also want to happen is when the date has been selected and the dropdown value is dated then the date field and the dropdown field will be set to read only.Anyone any ideas how to this usin...

when loading a previously created record on to form, some controls are missing values(controls are depended on values selected in other controls)
Hello - I have created a page for Editing records.  this page will open up a chosen record and allow user to edit the data.On the form, I have 3 drop down lists.   The second dropdown list should fill values depending on value chosen in first dropdown list.  The third dropdown list should show/fill values depending on value chosen in second dropdown list.So taking this into count, i have several records with various data.  When I open-up/load a record in Edit form, only the first dropdown list has a value selected that was the pre-existing va...

selected value of DDL contained in a user control
Hi all, I have this code in my page_load event of my user control. If Not IsPostBack() Then LoadLocations(lstLocation) 'lstLocation.Attributes.Add("onchange", "javascript: document.Form1.submit()") Select Case strDisplayMode.ToUpper Case "RESULTS" poPurchaseOrders.Find(strRequestedBy, strRaisedBy, strApprovedBy, strMatterNumber, strPurchaseOrderNumber, strOffice, intPageNumber, intRecordsOnPage) Case "MYLIST" poPur...

Selected values in Checked listbox in repeater control
Hi How do I retrieve the selected values in a checked listbox that is contained in a data repeater. <asp:repeater id=dl runat="server" DataSource="<%# bound %>">                                 <HeaderTemplate>                                     <TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="1"&g...

checking for a null value returned from a SELECT in
I am executing a SELECT statement, one time it is executed  the "category" does not exist in the db. How do I check that NULL was returned so I dont get an error trying to access it? At the moment I get the following error message "System.IndexOutOfRangeException: Index 0 is either negative or above rows count."  Dim category As StringDim productDV As DataViewDim arg As New DataSourceSelectArguments productDV = SqlDataSource1.Select(arg)     If Not IsDBNull(productDV(0)("Category")) Thencategory = LCase(productDV(0)("Categ...

Custom field controlled by other fields value
Hi i want to create a custom field with values shared by only 2 or 3 products for example. the only way i found is to duplicate this value 3 times (numbers of products having this field value). this is impossible because there is a constraint on the value of the custom field on the database. do you think that i can drop the constraint concerning this field from the database? Thanks a lot Fida On 10/22/2010 07:32 AM, fida wrote: > do you think that i can drop the constraint > concerning this field from the database? No, Bugzilla will not function properly with dupl...

Field that controls the values that appear in this field...
SGVsbG8gRXZlcnlib2R5IQ0KDQpJJ20gd29ya2luZyBvbiBpbXBsZW1lbnRpbmcgYSBuZXcgaW5z dGFuY2Ugb2YgQlogNC40LjIgSSBuZWVkIHRvIGFkZCB0aGUgZm9sbG93aW5nIGZpZWxkczoNCg0K MS4gRGlzdHJpY3QNCjIuIFNjaG9vbCBEZXBlbmRzIG9uIERpc3RyaWN0DQozLiBUZWFjaGVyICBE ZXBlbmRzIG9uIFNjaG9vbA0KDQpJIGNvdWxkIGRvIHRoZSBSZWxhdGlvbnNoaXAgYmV0d2VlbiB0 aGVtLCBidXQgdGhlIGlzc3VlIGlzIEkgaGF2ZSBsaWtlIDUwMCsgdGVhY2hlcnMsIHNvIHdoZW4g SSB0cmllZCB0byBjcmVhdGUgYSBidWcgaXQgdGFrZXMgYSBsb25nIHRpbWUgYW5kIEkgaGF2ZSBl cnJvciBvbiB0aGUgY2hyb21lLCBJIGd1ZXNzIGlzIGZvciB0aGUgYW1vdW50IG9mIGluZm8gb24g Y2ZfdGVhY2hlciB0YWJsZS4NCg0KSXMgdGhlcmUgYSB3YXkgSSBjYW...

Field that controls the values that appear in this field
--_009_EEA7F24FEA5EDC42BC3FD72846A5D8F84138437CAMSPRD0711MB593_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, Can I use the option of "Field that controls the values that appear in this= field" for non-custom fields? Thanks, Shalom. Shalom Shevach | QA Manager Comigo Ltd. O: +972- 9-771-5090 Ext. 119 | F: +972- 9-771-5091 |<http= ://> E-mail:<> [Description: Description: Comigo]<

GridView: ObjectDataSource has no values to insert. Check that the 'values' dictionary contains values.
Hi, I have a grid view, bound to the following object data source: <asp:ObjectDataSource ID="_odsMySampleTable"  runat="server"  SelectMethod="OnSelectAll" TypeName="SampleObjectDataSourceController" DataObjectTypeName="MyItem" InsertMethod="OnInsertItem" ></asp:ObjectDataSource> My OnInsertItem has the following signature: [DataObjectMethod( DataObjectMethodType.Insert )]public int OnInsertItem( MyItem item ) { ... } Now when I make the following call: _odsMySampleTable.Insert(); I get the following error: Exception Details: System.InvalidOperationExceptio...

setting a detailsview template field textbox value to the selected date of a calendar control
Is it possible to set the value of a template field textbox to the selected date from a calendar. If possible, please give me a some how detailed clue as i have struggled with accessing template fields for abit too long. I have posted quite  a number of posts related to this but upto now no one seems to lead me out. Thanks. --------------------------------------------------No Project Too Eazy.-------------------------------------------------- Hey Nick, You can set value of a template field textbox to whatever value in rowdatabound event. e.Row.Cells(1).Text = "whatva...

checking the value of a parent control in a user control
hi, how could i check the value of a textbox in the parent form withing the user control page_load event. The page load event in user control loads on postback and i want to check the value then and then either do stuff there You can expose a property in the user control. And set this property from the parent page.~ Firoz AnsariPune, Indiahttp://www.firozansari.comWhy product testing is important?...

ObjectDataSource 'odsUser' has no values to insert. Check that the 'values' dictionary contains values
Hi All! I am currently trying to pull 2 values from two different sources (Details View & a Session) to use in a Stored Proceedure.  I have spent quite a bit of time trying to determine what is occuring without any luck. However, by the Subject Line you can tell that it's not getting anything for some reason?  Here are the components:Object Datasource:<asp:ObjectDataSource ID="odsUser" runat="server" DataObjectTypeName="System.Nullable`1[[System.Int32, mscorlib, Version=, Culture=neutral, PublicKeyToken=************]]"DeleteMethod="RemoveEnrollment...

Looking for a control which can select a value or input a value
As I knew, dropdown list can only allow user to select a value. Is there any control let user to select a value or input a value? it depends on your requirement ... you will have to create a custom control ..what are you trying to do ? Please remember to click “Mark as Answer” on the post if this answer helps you.Abdulla AbdelHaqMCTS, MCPDHow to ask a question What I need is to list about 15 items to let user select. Also, user can input a item which is not under list.  so .. what is the problem of using textbox and listbox ?or gridview control, use the insert mode and create a ...

Web resources about - Checking if selected field contain value -

Checking whether a coin is fair - Wikipedia, the free encyclopedia
In statistics , the question of checking whether a coin is fair is one whose importance lies, firstly, in providing a simple problem on which ...

Facebook As A Means Of Credit Checking
How you socialize online, who with, and how often can make or break your loan application : True or false? It is true, surprisingly. And it is ...

Checking in at the World Cup and Leaving with Friends
... to the 2014 World Cup and we wanted to take a closer look at those who used Facebook to stay connected while they were in Brazil, checking into ...

State of Journalism: The Lost Art of Fact Checking
... Read all the posts here.It wasn’t exactly Bright Lights, Big City. Jay McInerney’s well State of Journalism: The Lost Art of Fact Checking March ...

Diver Checking Underwater Protection of Cable - Flickr - Photo Sharing!
Diver checking underwater protection of cable at hydroacoustic station HA08 at the British Indian Ocean Territory (BIOT), U.K. Copyright CTBTO ...

ESPN's Ray Lewis caught checking his phone on live TV for 20 seconds - YouTube
The Indianapolis Colts are gearing up for a Monday night AFC East clash against the New York Jets. The Colts are looking for their first win ...

Q&A: Checking rego date
Hugo is wondering what is the best way to check vehicle registration date now that cars no longer have rego labels in NSW.

Q&A: Checking rego date
Hugo is wondering what is the best way to check vehicle registration date now that cars no longer have rego labels in NSW.

Australian police checking MH17 site
Independent monitors are helping Canberra negotiate with armed rebels over access to the MH17 crash site.

Q&A: Checking rego date
Hugo is wondering what is the best way to check vehicle registration date now that cars no longer have rego labels in NSW.

Resources last updated: 11/24/2015 10:33:22 AM