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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Problem getting same record when trying to populate data into texboxes when selecting a row/record f

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net

I can't seem to get the select record from the datagrid to populate in the textboxes. I get the same record no matter what I select in the datagrid. Hopefully someone can help with this. I tried using a where clause for POPULATION_LIST_ID = '" & Me.lblPopulationID.Text & "' and I get a ORA-01722 error - invalid number. Here is the code I have so far for the grid:

  Protected Sub MHGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MHGrid.SelectedIndexChanged
Me.Table1.Visible = True
Me.MHGrid.Visible = True

Dim dvSql As DataView = DirectCast(MHFoundation.Select(DataSourceSelectArguments.Empty), DataView)

For Each drvSql As DataRowView In dvSql
Me.lblPopulationID.Text = drvSql("POPULATION_LIST_ID").ToString
Me.txtMRN.Text = drvSql("MRN1").ToString()

View Complete Post

More Related Resource Links

problem...i want a list item to populate all data in gridview!!!


i have a dropdownbox and a gridview

what I want is to have a list item which populates all data in a gridview.

I have tried using list item selected value=0 but to no avail.

what is the easiest way to achieve this?

Automatically set a property value for a new record in a Dynamic Data application.


I have a SalesOrderItem table, and it has a UnitPrice column in case the salesperson wishes to override the unit price of the Product for that order item.

In an ASP.NET Dynamic Data application, what would be the best way to set that UnitPrice property on a new SalesOrderItem based on the standard UnitPrice for the product? In other words, when the user clicks New on the 'Items' screen for a sales order, the UnitPrice field should already be filled in with the normal unit price for the product.

This was originally asked by myself on StackOverflow at: http://stackoverflow.com/questions/3538234/automatically-set-a-property-value-for-a-new-record-in-a-dynamic-data-application

Linq getting data from field on record



   I would assume this is possiable but I cannot seem to find it anywhere. I just one the contents of a single field, I don't see why I have to return the how

record to get get that information, here is my current code, how can I make this better without returning the entire record, for just getting contents of one field.

var patternrecord = storedb.Patterns_Table.Single(a => a.Pattern_GUID == id);
PMEDIA.Pattern_Key = patternrecord.Pattern_Key;

[newbie] How to return a data record from a webservice (wsdl)?



vs2010, .NET 4.0

I have a webmethod which I want to return a data record (for example: name, surename, address, age, zip etc)

I wonder how to accomplish this. I think the solution is about creating an object which contains all the records serialized. And then the webmethod returns this serialized object. I'm not 100% sure how to accomplish this, if some of you good provide me with some tips, tutorial or link to an article explaining it, that would be great

Problem Select ancestors a Record

Hi; I have a table by three columns ("ID","Title","ParentID"),me want to select ancestors a Record by "ID" identifier. example: ID      Title       ParentID 1         Library       null 2         Section1      1 3        Section2       1 4        1.1              2   for example if record 4 selected return records by "ID" identifier 2,1 How can me do it?  

Getting the data's next record, by clicking a button

Hi sorry if asked this twice, please help me understand how to get the next or before record from the database as from the below code i am only getting one record up, and please provide with code as i understand it better that way not that i am in a rush or anything.... thankyou.. please take a look at the code below private void button1_Click(object sender, RoutedEventArgs e) { NorthwindLINQDataContext mycontext = new NorthwindLINQDataContext(); var myquery = from myrow in mycontext.Orders select new { CID = myrow.CustomerID, EmpId = myrow.EmployeeID, OID = myrow.OrderID }; //This will retrieve all records from the db foreach (var valuesFromQuery in myquery) { textBox1.Text = valuesFromQuery.CID; textBox2.Text = valuesFromQuery.EmpId.ToString(); textBox3.Text = valuesFromQuery.OID.ToString(); } } private void NEXT_Click(object sender, RoutedEventArgs e) { NorthwindLINQDataContext mycontext = new NorthwindLINQDataContext(); } private void BEFORE_Click(object sender, RoutedEventArgs e) { NorthwindLINQDataContext mycontext = new NorthwindLINQDataContext(); } } D.Boy

Cannot INSERT record using Asp.Net Dynamic Data Domain Service Web Applications

 Hi, I am working on a 'Asp.Net Dynamic Data Domain Service Web Application' project using just 2 tables, FAQ_Categories and FAQs. The FAQs table has a foreign key to the FAQ_Categories. The steps are straight forward. Add a new project (Asp.Net Dynamic Data Domain Service Web Applications) Add folders Model ( for Linq2Sql datacontext), Domain (for the Domain Services class) Add Linq2Slql and add the 2 tables to the designer. Build the project. Add the Domain Service Class to the Domain folder. in the wizard select the DataContext, uncheck the Enable Client & Expose ODate checkbox Check bothe table & their corresponding Enable Editing tables checbox Check the Generate Metadata class Click OK. In Global.asax set Scaffold to true and add the DomainService name. Build and run.   Pages List and Detail are working fine. But if I try to insert a new record, I get the error "FaqId is required" Faq_ID is the primary key in the database table and it is set to Identiy. The Datacontext is correct, it marked the FAQ table with <Global.System.Data.Linq.Mapping.ColumnAttribute(Storage:="_CustomerId", AutoSync:=AutoSync.OnInsert, DbType:="Int NOT NULL IDENTITY", IsPrimaryKey:=true, IsDbGenerated:=true)> _   I tried this using Linq2Sql, Entity Framework, And both in VB and C# with the same result. I am using VS20

Updating record in sql databse using data from Gridveiw or Formview

Hi Guys, I am making a message module in asp.net with database of sql. i have made a gridview and enabled selecting. and a form view is synchorised with grid view on selecting. i am writing update sql but could not get a way to take data on Gridview or Formview to compare the record in sql database.   this is my page viewImports System.Data Imports System.Data.SqlClient Partial Class homepage Inherits System.Web.UI.Page Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged FormView1.PageIndex = GridView1.SelectedIndex Label1.Text = FormView1.FooterText. End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Session("login") = False Then Response.Redirect("Login.aspx") End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim db As New SqlConnection db.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Message_Dat.mdf;Integrated Security=True;User Instance=True" db.Open() Dim sql As String = "update into tblMessage (msg_status) values('junk') where msg_Id='" & FormView1.text & &q

help on triggers inserting record problem?


I have created a trigger and i want to insert a record in emp table whenever i insert i must get the confirmation that record is added i want to do this

using triggers.

USE [mine]
/****** Object:  Trigger [dbo].[insert2]    Script Date: 10/03/2010 09:06:59 ******/
ALTER trigger [dbo].[insert2]  
   on [dbo].[emp]  
    for insert  
    declare @sno int,@result varchar(50),@empid int,@name varchar(50)  
    select @empid=empid,@name=@name from emp where @empid=empid 
    insert into triglog values (@empid,@name)  

above is my code emp is my primary table and triglog is the table where i want to get the confirmation that data is aded when a new record is inserted into emp,actually i want to know when a new record is added? is there anyway to know this when i execute the code im getting error like inserting null values into sno and result but how to pull the values from emp and enter it in triglog im confused help with this??thanks.

Selecting record based on domain url and email comparison


I want to limit the selecting of data records to only the user who created the record, OR a users who's email address belongs to the domain of the record being edited.
So, if the producer has a value in the URL of "www.mydomain.com" and their email address in the Membership is "someone@mydomain.com" they will be able to see the record.

I have the following table:
Table -  Producer
Field: ProducerID
Field: ItemUserID
Field: URL

I have figured out how to select based on the ItemUserID (see code below), but I don't know how to compair the email address values of URL and the Membership.

protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
      if (Page.User.Identity.IsAuthenticated)
     //get id of user logged in
     e.Command.Parameters["@ItemUserID"].Value = Membership.GetUser().ProviderUserKey;

Can someone show me how to code my requirements?

sql count record problem


if i have a prodcut with product no. and each product is made by many parts with parts no.
now i would like to retrieve data to count how many parts to make a product.
in sql, can i count parts no. by each product no. like belows:

select product_no,parts_name,manufacture_date,(select count(*) from item where product_no=p.product_no) as [No. of items] from prodcut p left outer join item i on p.product_no=i.product_no

but i found that the execution time is too long, is it the right way to count no. of item in each product??

Problem when creating a Record Center in SharePoint 2010


Hi Guys

I have a problem when creating a Record Center in SharePoint 2010 on a publishing Portal. The Record center creates succesfully, but when I try to upload a record sharepoint says that the list does not exist, also when I try to go into the site settings of the record center I get the same issue. When trying to specify the libraries in the record centre management page....same thing! What could this be? 

Sql query to put data in one sngle record


i have one parent table and one child table.

so in parent table only one records will stay for one bunch of records and remaing records will pushed into child table.so scenario may be like this in MSATER table for one record there may be 3 reords in child table

2-in MSATER table for one record there may be 5 reords in child table

3-in MSATER table for one record there may be 10 reords in child table and so on..

parent table                                                 Child table

id  Student_name   age   phone                 id  Student_rollno   Student_name  FatherNAme
1     manoj        23  42846209862            1       34             manoj           Deepak
						    1       23             ramesh          Kailash
						    1       45             raja              tara	

I want data in this format 	    
id  Student_name   age   phone            FatherNAme1  FatherNAme2 FatherNAme3	
1           manoj    23    42846209862        Deepak     Kailash		tara		

But currently we have 3 records but if I have 10 records then also tha data comes in similar fashion means(	FatherNAme1   coloumns repeat 10 time)
How can I do this.I need to store data in a single row.						


Problem inserting a record into database

I created a table with a foreign key:
Create table Products
    Pro_ID int Primary key not null, 
    Client_ID int Foreign key (Client_ID) references Client_Details not null,
    [Prod_Name] [varchar](50) NULL,
    Prod_Description varchar(50) null,
    Purchase_Date DateTime Not null,
    Price Money null,
    Delivered int null
I need to populate that table with some data:
insert into Products (Pro_ID,Client_ID,Prod_Name,Prod_Description,Purchase_Date,Price)
values(2024,102,'Valuation Roll 2001','Property Values for 2001',Getdate(),15000)
When I run the query I get an error:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK__Products__Client__03317E3D". 
The conflict occurred in database "valrollclients", table "dbo.client_details", column 'client_id'.
The st

Workflow. Copy item to new list - problem updating additional fields in the new list record




I'm having a couple of problems


I have a list, List A. On a couple of triggers I want list A to copy fields to a new record in List B.

Many of the columns are the same Say, column1, column 2, colmn 3. The Copy Item is working fine.


I then want to amend several fields in the new record in List B to reflect the new info from list A, and create info in a fields (say ListBcolum4 type choice and ListBcolum5 single line).

For the life of me I cant get this to work... ive tried updating fields, creating items...

A pointer on how to do this would be greatfully received.

EntityDataSource selecting specif record when loading


I have a formview and an entitydatasource on my aspx page.

I have some code in my aspx.cs page in the page_load event.

The code is saving data to a sqlserver 2005 table.

After I have saved the data. I want to show that data in the formview.

the formview id=FormView1 and EntityDatasource id=edsPDT

here is where I am in my code behind. I am trying to get edsPDT to select the record that I have just saved.

                PDTrecId = PDTrecord.id;
                PDTrecordSuccess = true;
                edsPDT.Where = @"UBOecPDT.id=" + PDTrecId.ToString();

 I am not even really sure if I should be using the .Where property here.

Or should I be doing some sort of edsPDT.Select(GetmyPDTrecId)?????

If someone could point me in the right direction ....

Thanks, John Feeney

how to pass a xml data record dynamically into a parameter


Hi all,

I just want to know how to send a xml record in a table into a parameter dynamically ! Is this possible? If yes please reply me


 i need to set @parameter1 = select * from dbo.DB_CUSTOMERS for XML PATH , ROOT ('Customers')

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