Click here to Skip to main content
15,906,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I place values from mysql into repeater

and have some values to be calculated for each row , and then display only that value in repeater according to the id ...

for exp.

in mysql i have values


name surname price

maulik shah 258
perva rasool 123
sharer taval 147


Now , i want to add 25 to price for maulik, add 85 to perva ,and same price for sharer in aspx.cs code behind and then set in repeater ,,,

or set first datasource in repeater and then make changes..

or u suggest



i hope you understood..
Posted

1 solution

you can set values to the dataset using ado.net features.
when you get data from sql

use datatable object and change the values as per you need like below

C#
for(int i = 0;i<dt.roww.count;i++)
{
if(discount != 0)
{
double newvlaue = oldvalue +  (oldvalue * discount)/100;

datatable.rows[0]["price"] = newvlaue 
}
else 
{
keep price as it is 
}

datatable.acectpchanges();
repeater.datasource = datatable;
repeater.databind();
}
 
Share this answer
 
v3
Comments
maulikshah1990 4-Feb-14 5:46am    
Hi
i get mysql into dataset, then i need to check if discount!=0 , then take price for that rows, calculate according to discount. and update price in dataset and then datasource and databind to asp:repeater..
ravikhoda 4-Feb-14 6:00am    
please check solution again maybe this one help you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900