System.reflection.targetexception non-static method requires a target - reflection

public IQueryable<DebitorProductCautionsEx> GetEx(
Expression<Func<DebitorProductCautions, bool>> filter = null,
SearchDto search = null,
int? lawyerID = null,
bool? IsInDetailTab = null
)
{
filter = filter ?? (p => true);
search = search ?? new SearchDto();
IsInDetailTab = IsInDetailTab ?? false;
//this line about authorization
var hyDepList = context.Department.Where(p => p.ID == UserData.iDepartmentId && p.ID != 0).RecursiveSelect(p => context.Department.Where(pd => pd.ParentID == p.ID).AsQueryable<Department>()).Select(p => p.DepartmentBankCode).Distinct().ToList();
//this line about authorization
var associatedDepartmenList = (from depID in context.DepartmentUserAssociation.Where(p => p.AssociateAccountUserID == UserData.iUserId && p.AssociateAccountUserID != 0).Select(p => p.DepartmentID)
join dep in context.Department on depID equals dep.ID
select dep.DepartmentBankCode).Distinct().ToList();
var query = from item in dbSet.Where(filter)
join debitor in context.Debitor on item.DebitorID equals debitor.ID
//kurumsal
from debitorProducts in context.DebitorProducts.Where(p => !p.IsDeleted && p.DebitorID == debitor.ID).OrderBy(a => a.TrackingDate).Take(1).DefaultIfEmpty()
from product in context.Product.Where(p => !p.IsDeleted && p.ID == debitorProducts.ProductID).DefaultIfEmpty()
//bireysel
from debitorProducts2 in context.DebitorProducts.Where(p => !p.IsDeleted && p.ID == item.DebitorProductsID).DefaultIfEmpty()
from product2 in context.Product.Where(p => !p.IsDeleted && p.ID == debitorProducts2.ProductID).DefaultIfEmpty()
from delegationDebitorProduct in context.MainLawyerDelegationDebitorProduct.Where(p => (p.DebitorProductID.HasValue && ((debitor.MistralCustomerStatusID == 3 || debitor.MistralCustomerStatusID == 8) ? p.DebitorProductID == debitorProducts2.ID : p.DebitorProductID == debitorProducts.ID))).DefaultIfEmpty()
from delegation in context.MainLawyerDelegation.Where(p => !p.IsDeleted && p.ID == delegationDebitorProduct.MainLawyerDelegationID).DefaultIfEmpty()
from debitorType in context.DebitorType.Where(p => !p.IsDeleted && p.ID == debitor.DebitorTypeID).DefaultIfEmpty()
from exchangeType in context.ExchangeType.Where(p => !p.IsDeleted && (item.ExchangeTypeID.HasValue && p.ID == (int)item.ExchangeTypeID)).DefaultIfEmpty()
from insertedAccountUser in context.AccountUser.Where(p => p.ID == item.InsertedBy).DefaultIfEmpty()
from insertedAccountPerson in context.AccountPerson.Where(p => p.ID == insertedAccountUser.PersonID).DefaultIfEmpty()
from updatedAccountUser in context.AccountUser.Where(p => p.ID == item.UpdatedBy).DefaultIfEmpty()
from updatedAccountPerson in context.AccountPerson.Where(p => p.ID == updatedAccountUser.PersonID).DefaultIfEmpty()
where
(!search.DebitorID.HasValue || debitor.ID == search.DebitorID)
&& (search.DebitorNo == null || debitor.DebitorNo == search.DebitorNo)
&& (search.TCKNOrTaxOfficeNumber == null || debitor.TCKN == search.TCKNOrTaxOfficeNumber || debitor.TaxOfficeNumber == search.TCKNOrTaxOfficeNumber)
&& (search.FirstName == null || debitor.Name.Contains(search.FirstName))
&& (search.Surname == null || debitor.Surname.Contains(search.Surname))
&& (search.BankCode == null || context.DebitorProducts.Any(p => !p.IsDeleted && p.DebitorID == debitor.ID && p.TrackingUnitCode == search.BankCode))
&& (search.PhoneNo == null || context.DebitorPhones.Any(p => !p.IsDeleted && p.DebitorID == debitor.ID && p.PhoneNo.Contains(search.PhoneNo)))
&& (search.ExecutionFileNo1 == null || context.ExecutionTracking.Any(p => !p.IsDeleted && p.DebitorID == debitor.ID && p.ExecutionFileNo.StartsWith(search.ExecutionFileNo1.ToString())))
&& (search.ExecutionFileNo2 == null || context.ExecutionTracking.Any(p => !p.IsDeleted && p.DebitorID == debitor.ID && p.ExecutionFileNo.EndsWith(search.ExecutionFileNo2.ToString())))
&& (!search.LawyerID.HasValue || !delegationDebitorProduct.IsDeleted && delegation.Status == (int)LawyerConfirmStatus.Accept && (delegation.MainLawyerID == search.LawyerID || delegation.ObserverLawyerID == search.LawyerID))
&& (!lawyerID.HasValue || !delegationDebitorProduct.IsDeleted && delegation.Status == (int)LawyerConfirmStatus.Accept && (delegation.MainLawyerID == lawyerID || delegation.ObserverLawyerID == lawyerID))
&& ((!(context.AccountRole.Where(p => p.KimyonCode == "B" || p.KimyonCode == "SP" || p.KimyonCode == "SM").Select(p => p.ID).Contains(UserData.iRoleId))) || hyDepList.Contains(debitorProducts.TrackingUnitCode.ToString()))
&& ((!(context.AccountRole.Where(p => p.KimyonCode == "MM" || p.KimyonCode == "MTL" || p.KimyonCode == "MP").Select(p => p.ID).Contains(UserData.iRoleId))) || associatedDepartmenList.Contains(debitorProducts.TrackingUnitCode.ToString()))
select new DebitorProductCautionsEx
{
ID = item.ID,
DebitorID = debitor.ID,
DebitorProductsID = item.DebitorProductsID,
ExchangeTypeID = item.ExchangeTypeID,
NotaryName = item.NotaryName,
ReferenceNo = item.ReferenceNo,
DailyChargeNo = item.DailyChargeNo,
CautionDate = item.CautionDate,
CautionPeriod = item.CautionPeriod,
NotificationDate = item.NotificationDate,
BankStatementDate = item.BankStatementDate,
BSMVRate = item.BSMVRate,
KKDFRate = item.KKDFRate,
CautionAmount = item.CautionAmount,
CapitalAmount = item.CapitalAmount,
InterestAmount = item.InterestAmount,
CommissionAmount = item.CommissionAmount,
LegalWageCutAmount = item.LegalWageCutAmount,
CautionCashAmount = item.CautionCashAmount,
CautionNonCashAmount = item.CautionNonCashAmount,
TotalDebt = item.TotalDebt,
MistralCustomerStatusID = debitor.MistralCustomerStatusID,
DebitorNo = debitor.DebitorNo,
DebitorName = (debitor.MistralCustomerStatusID == 3 || debitor.MistralCustomerStatusID == 8) ? debitor.Name.Replace(" ", "") + " " + debitor.Surname.Replace(" ", "") : debitor.Name,
DebitorSurname = debitor.Surname,
TCKN = debitor.TCKN,
NCN = debitor.NCN,
isKurumsal = (debitor.MistralCustomerStatusID != 3 && debitor.MistralCustomerStatusID != 8),
ProductName = (debitor.MistralCustomerStatusID == 3 || debitor.MistralCustomerStatusID == 8) ? product2.ProductName : (item.DebitorProductsID == 0 ? "KURUMSAL KREDİ" : product.ProductName),
ExchangeType = exchangeType.Description,
BSMV = (debitor.MistralCustomerStatusID == 3 || debitor.MistralCustomerStatusID == 8) ? (item.InterestAmount.HasValue ? Math.Truncate(((item.InterestAmount.Value * 5) / 100) * 100) / 100 : 0) : 0,
KKDF = (debitor.MistralCustomerStatusID == 3 || debitor.MistralCustomerStatusID == 8) ? (item.InterestAmount.HasValue ? Math.Truncate(((item.InterestAmount.Value * 15) / 100) * 100) / 100 : 0) : 0,
UpdateDate = item.UpdateDate,
InsertedBy = item.InsertedBy,
UpdatedBy = item.UpdatedBy,
InsertDate = item.InsertDate,
IsDeleted = item.IsDeleted,
InsertedName = insertedAccountPerson.FirstName.Trim() + " " + insertedAccountPerson.LastName.Trim(),
UpdatedName = updatedAccountPerson.FirstName.Trim() + " " + updatedAccountPerson.LastName.Trim()
};
if (IsInDetailTab.Value)
{
return query;
}
var bireysel = new List<int>(); // Müşteri Tipi Bireysel olan ihtar ID'leri listesi.
var kurumsal = new Dictionary<string, int>(); // Müşteri Tipi Kurumsal olan İhtarların DebitorId ve Yevmiye No'ya göre gruplanmış listesi.
//porblem is query non-static method
**foreach (var item in query.OrderByDescending(p => p.ID).ToList())**
{
var deb = context.Debitor.FirstOrDefault(p => p.ID == item.DebitorID);
if (deb != null && (deb.MistralCustomerStatusID == 3 || deb.MistralCustomerStatusID == 8))
{
bireysel.Add(item.ID);
continue;
}
var key = string.Concat(item.DebitorID, "-", item.DailyChargeNo);
if (kurumsal.ContainsKey(key))
continue;
kurumsal.Add(key, item.ID);
}
var datKurumsal = query.Where(p => kurumsal.Values.Contains(p.ID));
var datBireysel = query.Where(p => bireysel.Contains(p.ID));
return datBireysel.Union(datKurumsal);
}

Related

Uncaught SyntaxError: expected expression, got keyword 'var' on she-header.js

I'm new to this forum and am currently receiving the error Uncaught SyntaxError: expected expression, got keyword 'var' on my she-header.js beginning at console.log and ending at header height shrink. Any help would be much appreciated. I have not tried much, and the support available is not very informative about this problem.
var $j = jQuery.noConflict();
$j( document ).ready( function() {
"use strict";
// She header
sheHeader();
} );
/* ==============================================
HEADER EFFECTS
============================================== */
function sheHeader() {
var header = $j('.she-header-yes'),
container = $j('.she-header-yes .elementor-container, .she-header-yes.e-container'),
header_elementor = $j('.elementor-edit-mode .she-header-yes'),
header_logo = $j('.she-header-yes .elementor-widget-theme-site-logo .elementor-image, .she-header-yes .elementor-widget-image .elementor-image'),
data_settings = header.data('settings');
if ( typeof data_settings != 'undefined' ) {
var responsive_settings = data_settings["transparent_on"];
var width = $j(window).width(),
header_height= header.height(),
logo_width = header_logo.width(),
logo_height = header_logo.height() ;
}
// Check responsive is enabled
if( typeof width != 'undefined' && width) {
if( width >= 1025 ) {
var enabled = "desktop";
}else if (width > 767 && width < 1025 ) {
var enabled = "tablet";
}else if (width <= 767 ) {
var enabled = "mobile";
}
}
console.log($j.inArray(enabled, responsive_settings));
if ($j.inArray(enabled, responsive_settings)!='-1') {
var scroll_distance = data_settings["scroll_distance"];
var transparent_header = data_settings["transparent_header_show"];
var background = data_settings["background"];
var bottom_border_color = data_settings["custom_bottom_border_color"],
bottom_border_view = data_settings["bottom_border"],
bottom_border_width = data_settings["custom_bottom_border_width"];
var shrink_header = data_settings["shrink_header"],
data_height = data_settings["custom_height_header"],
data_height_tablet = data_settings["custom_height_header_tablet"],
data_height_mobile = data_settings["custom_height_header_mobile"];
var shrink_logo = data_settings["shrink_header_logo"],
data_logo_height = data_settings["custom_height_header_logo"],
data_logo_height_tablet = data_settings["custom_height_header_logo_tablet"],
data_logo_height_mobile = data_settings["custom_height_header_logo_mobile"];
var change_logo_color = data_settings["change_logo_color"];
var blur_bg = data_settings["blur_bg"];
var scroll_distance_hide_header = data_settings["scroll_distance_hide_header"];**
// add transparent class
if(transparent_header == "yes" ){
header.addClass('she-header-transparent-yes');
}
// header height shrink
if( typeof data_height != 'undefined' && data_height) {
if( width >= 1025 ) {
var shrink_height = data_height["size"];
}else if (width > 767 && width < 1025 ) {
var shrink_height = data_height_tablet["size"];
if(shrink_height == ''){
shrink_height = data_height["size"];
}
}else if (width <= 767 ) {
var shrink_height = data_height_mobile["size"];
if(shrink_height == ''){
shrink_height = data_height["size"];
}
}
}
// border bottom
if( typeof bottom_border_width != 'undefined' && bottom_border_width) {
var bottom_border = bottom_border_width["size"] + "px solid " + bottom_border_color;
}
// hide header on scroll
if( typeof scroll_distance_hide_header != 'undefined' && scroll_distance_hide_header) {
var mywindow = $j(window);
var mypos = mywindow.scrollTop();
mywindow.scroll(function() {
if (mypos > scroll_distance_hide_header["size"]) {
if(mywindow.scrollTop() > mypos)
{
header.addClass('headerup');
}else{
header.removeClass('headerup');
}
}
mypos = mywindow.scrollTop();
});
}
// scroll function
$j(window).on("load scroll",function(e){
var scroll = $j(window).scrollTop();
if (header_elementor) {
header_elementor.css("position", "relative");
}
if (scroll >= scroll_distance["size"]) {
header.removeClass('header').addClass("she-header");
header.css("background-color", background);
header.css("border-bottom", bottom_border);
header.removeClass('she-header-transparent-yes');
if( shrink_header == "yes" ) {
header.css({"padding-top":"0", "padding-bottom":"0", "margin-top":"0", "margin-bottom":"0"});
container.css({"min-height": shrink_height, "transition": "all 0.4s ease-in-out", "-webkit-transition": "all 0.4s ease-in-out", "-moz-transition": "all 0.4s ease-in-out"});
}
if( change_logo_color == "yes" ) {
header_logo.addClass("change-logo-color");
}
if( blur_bg == "yes" ) {
header.css({"backdrop-filter": "saturate(180%) blur(20px)", "-webkit-backdrop-filter": "saturate(180%) blur(20px)"});
}
} else {
header.removeClass("she-header").addClass('header');
header.css("background-color", "");
header.css("border-bottom", "");
if(transparent_header == "yes" ){
header.addClass('she-header-transparent-yes');
}
if( shrink_header == "yes" ) {
header.css({"padding-top":"", "padding-bottom":"", "margin-top":"", "margin-bottom":""});
container.css("min-height", "");
}
if( change_logo_color == "yes" ) {
header_logo.removeClass("change-logo-color");
}
if( blur_bg == "yes" ) {
header.css({"backdrop-filter": "", "-webkit-backdrop-filter": ""});
}
}
});
}
};

Symfony 4 Match Against sort by relevanece

I want to sort by revelance that mean if i have in db:
FooBa
FooBar
FooB
Foo
and i want to type foo it will be sorted:
Foo
FooB
FooBa
FooBar
public function findBySearchQueryPagin2(string $rawQuery, int $limit = 999, string $sort = "DESC", string $sortBy = "relevance", int $page = 1): pagerfanta
{
$query = $this->sanitizeSearchQuery($rawQuery);
$sort = $this->sanitizeSearchQuery($sort);
$sortBy = $this->sanitizeSearchQuery($sortBy);
$limit = $this->sanitizeSearchQuery($limit);
$page = $this->sanitizeSearchQuery($page);
if(($sort != 'ASC')&&($sort != 'DESC')) $sort = 'DESC';
if(($sortBy != 'date')&&($sortBy != 'name')&&($sortBy != 'relevance')){
$sortBy = null;
} else {
if($sortBy=="name") $sortBy = "primarytitle";
if($sortBy=="date") $sortBy = "startyear";
if($sortBy=="relevance") $sortBy = "relevance";
}
$queryBuilder = $this->createQueryBuilder('p')
->andWhere("MATCH_AGAINST (p.primarytitle, :searchTerms) > 1")
->setParameter('searchTerms', $query)
->setMaxResults($limit);
var_dump($query);
if($sortBy !== "relevance"){
$queryBuilder
->orderBy('p.' . $sortBy, $sort);
}
return $this->createPaginator($queryBuilder->getQuery(), $page);
}

Constructing queries by using #Query annotation in Jpa repo

This is my logic for a query:
String customQuery = "";
customQuery = customQuery + "select * from Customer c where";
if (targetGroupDto.getGender() != null && !targetGroupDto.getGender().isEmpty()) {
customQuery = customQuery + " c.gender = " + targetGroupDto.getGender();
if (targetGroupDto.getAge() != 0
|| (targetGroupDto.getCity() != null && !targetGroupDto.getCity().isEmpty())
|| (targetGroupDto.getState() != null && !targetGroupDto.getState().isEmpty())) {
customQuery = customQuery + " and ";
}
}
if (targetGroupDto.getAge() != 0) {
customQuery = customQuery + " c.age = " + targetGroupDto.getAge();
if ((targetGroupDto.getCity() != null && !targetGroupDto.getCity().isEmpty())
|| (targetGroupDto.getState() != null && !targetGroupDto.getState().isEmpty())) {
customQuery = customQuery + " and ";
}
}
if (targetGroupDto.getCity() != null && !targetGroupDto.getCity().isEmpty()) {
customQuery = customQuery + " c.city = " + targetGroupDto.getCity();
if ((targetGroupDto.getState() != null && !targetGroupDto.getState().isEmpty())) {
customQuery = customQuery + " and ";
}
}
if (targetGroupDto.getState() != null && !targetGroupDto.getState().isEmpty()) {
customQuery = customQuery + " c.state = " + targetGroupDto.getState();
}
**
This is a class where i m writing the query and i am calling this
method in my service class
**
#Transactional
public class CustomerRepositoryImpl implements CustomerRepository {
#Autowired
private EntityManager entityManager;
#Override
public Set<Customer> filterCustomers(TargetGroupDto targetGroupDto) {
//CriteriaBuilder cb = entityManager.getCriteriaBuilder();
//CriteriaQuery<Customer> criteriaQuery = cb.createQuery(Customer.class);
//Root<Customer> customer = criteriaQuery.from(Customer.class);
Query query;
String customQuery = "";
customQuery = customQuery + "select * from Customer c where";
if (targetGroupDto.getGender() != null && !targetGroupDto.getGender().isEmpty()) {
customQuery = customQuery + " c.gender = " + targetGroupDto.getGender();
if (targetGroupDto.getAge() != 0
|| (targetGroupDto.getCity() != null && !targetGroupDto.getCity().isEmpty())
|| (targetGroupDto.getState() != null && !targetGroupDto.getState().isEmpty())) {
customQuery = customQuery + " and ";
}
}
if (targetGroupDto.getAge() != 0) {
customQuery = customQuery + " c.age = " + targetGroupDto.getAge();
if ((targetGroupDto.getCity() != null && !targetGroupDto.getCity().isEmpty())
|| (targetGroupDto.getState() != null && !targetGroupDto.getState().isEmpty())) {
customQuery = customQuery + " and ";
}
}
if (targetGroupDto.getCity() != null && !targetGroupDto.getCity().isEmpty()) {
customQuery = customQuery + " c.city = " + targetGroupDto.getCity();
if ((targetGroupDto.getState() != null && !targetGroupDto.getState().isEmpty())) {
customQuery = customQuery + " and ";
}
}
if (targetGroupDto.getState() != null && !targetGroupDto.getState().isEmpty()) {
customQuery = customQuery + " c.state = " + targetGroupDto.getState();
}
query = getEntityManager().createQuery(customQuery);
List<Customer> customers = query.getResultList();
Set<Customer> results = new HashSet<Customer>(customers);
return results;
}
**
I get this Null Pointer Exception on calling this method java.lang.NullPointerException at
com.thoughtclan.segmentationofcustomers.service.SocServiceImpl.filterDetails(SocServiceImpl.java:102)
at
com.thoughtclan.segmentationofcustomers.controller.SegmentationOfCustomersController.filterDetails(SegmentationOfCustomersController.java:73)
SegmentationOfCustomersController.java:73)-> customers =
socService.filterDetails(targetGroupDto);
SocServiceImpl.java:102)-> filteredCustomers =
customerRepositoryImpl.filterCustomers(targetGroupDto);
**

Hanging moving gestures (Left/normal/right/up/normal/down) using mpu9150 sensor

We tried (Arduino+mpu9150) using gestures LEFT-NORMAL-RIGHT, UP-NORMAL-RIGHT.
We can able to get these gestures, but not accurately.
Its HANGING in middle, and sometimes values are also Incorrect.
Could you please help me to fix this issue?
Please check complete code for an ++attachment.
CODE:
void guesture() {
//LEFT & RIGHT
//Starting Accelerartion condition
if ( diff_yaw < -250)
{
diff_yaw = -(360 + diff_yaw);
}
else if (diff_yaw > 250)
{
diff_yaw = 360 - diff_yaw;
}
if ((aaReal.y < -1500) && (flag1 == false) && (flag2 == false) ) {
old_time1 = new_time;
old_yaw = new_yaw;
flag1 = true;
} else if ((aaReal.y > 1000) && (flag2 == false) && (flag1 == false)) {
old_time1 = new_time;
old_yaw = new_yaw;
flag2 = true;
} else if (aaReal.z > 400 && flag11 == false) {
old_time = new_time;
flag11 = true;
} else if (aaReal.z < -400 && flag22 == false) {
old_time = new_time;
flag22 = true;
}
if ((aaReal.y > 1000) && (flag1 == true) && (flagZ1 == false)) {
flagZ1 = true;
} else if ((aaReal.y < -1500) && (flag2 == true) && (flagZ2 == false)) {
flagZ2 = true;
} else if (aaReal.z < -400 && flag11 == true) {
diff_time = new_time - old_time;
flag11 = false;
if (diff_time < 2000 ) {
flag33 = true;
old_time = new_time;
}
} else if (aaReal.z > 400 && flag22 == true) {
diff_time = new_time - old_time;
flag22 = false;
if (diff_time < 2000 ) {
flag33 = true;
old_time = new_time;
}
}
if ((aaReal.y < 1000) && (flagZ1 == true)) {
flag1 = false;
flagZ1 = false;
diff_yaw = new_yaw - old_yaw;
diff_time = new_time - old_time1;
if (diff_time < 2000)
{
flagN = true;
}
} else if ((aaReal.y > -1500) && (flagZ2 == true)) {
flag2 = false;
flagZ2 = false;
diff_yaw = new_yaw - old_yaw;
diff_time = new_time - old_time1;
if (diff_time < 2000)
{
flagN = true;
}
}
if (flagN == true) {
if (Iposition == 0 && diff_yaw > 0) { //Right
Iposition = 1;
flagR = true;
} else if (Iposition == 0 && (diff_yaw) < 0 ) { //Left
Iposition = 2;
flagL = true;
} else if (Iposition == 1 && (diff_yaw) < 0 && (diff_yaw) > -25) { //Right-Normal
Iposition = 0;
flagNL = true;
} else if (Iposition == 1 && (diff_yaw) < -25) { //Right-Left
Iposition = 2;
flagL = true;
} else if (Iposition == 2 && (diff_yaw) > 0 && diff_yaw < 25) { //Left-Normal
Iposition = 0;
flagNL = true;
} else if (Iposition == 2 && diff_yaw > 25) { //Left-Right
Iposition = 1;
flagR = true;
}
}
if (flagN == true || flag33 == true) {
if (flagR == true) {
Serial.println("POSITION : RIGHT");
flagR = false;
} else if (flagL == true) {
Serial.println("POSITION : LEFT");
flagL = false;
} else if (flagNL == true) {
Serial.println("POSITION : NORMAL");
flagNL = false;
} else if (Ipos == 0 && pO >= 20 ) {
Ipos = 1;
Serial.println("POSITION : UP");
} else if (Ipos == 0 && pO <= -20 ) {
Ipos = 2;
Serial.println("POSITION : DOWN");
} else if (Ipos == 1 && pO <= 10 && pO >= -10 ) {
Ipos = 0;
Serial.println("POSITION : NORMAL");
} else if (Ipos == 1 && pO < -5 ) {
Ipos = 2;
Serial.println("POSITION : DOWN");
} else if (Ipos == 2 && pO >= -10 && pO < 0) {
Ipos = 0;
Serial.println("POSITION : NORMAL");
} else if (Ipos == 2 && pO > 0 ) {
Ipos = 1;
Serial.println("POSITION : UP");
}
flagN = false;
flag33 = false;
}
}

how to add link button using datatable as datasource to gridview dynamically?

Here i did every thing from codebehind.I created a gridview dynamically.
DataTable dt=null;
dt = loadDynamicGrid(columnname, ds);
GridView grdnew = new GridView();
grdnew.DataSource = dt;
grdnew.DataBind();
private DataTable loadDynamicGrid(string [] column,DataSet ds)
{
#region Code for preparing the DataTable
DataTable dt = new DataTable();
//Create an ID column for adding to the Datatable
DataColumn dcol ;//= new DataColumn(ID1, typeof(System.Int32));
ButtonColumn btncolm;
HyperLinkColumn hplink;
for (int i = 0; i < column.Count(); i++)
{
if (column[i] != "" & column[i]!=null)
{
if (column[i] == "BUY" || column[i] == "Buy" || column[i] == "BuyNow" || column[i] == "Details" || column[i] == "ViewDetails" || column[i] == "BuyQty" || column[i] == "Purchase")
{
//btncolm = new ButtonColumn();
//btncolm.HeaderText = column[i];
//btncolm.Text = column[i];
//dt.Columns.Add(btncolm.Text);
hplink = new HyperLinkColumn();
hplink.HeaderImageUrl = "http://www.google.com";
hplink.HeaderText = column[i];
hplink.Text = column[i];
dt.Columns.Add(hplink.Text);
}
else
{
dcol = new DataColumn(column[i], typeof(System.String));
dt.Columns.Add(dcol);
}
}
}
int k=0;
foreach (DataRow dr in ds.Tables[0].Rows)
{
DataRow myrow = dt.NewRow();
for (int j = 0; j < column.Count(); j++)
{
if (column[j] != "" & column[j] != null)
{
string sdfsd = Convert.ToString(dr[column[j]]);
if (column[j] == "BUY" || column[j] == "Buy" || column[j] == "BuyNow" || column[j] == "Details" || column[j] == "ViewDetails" || column[j] == "BuyQty" || column[j] == "Purchase")
{
//myrow[column[j]] = "http://www.google.com1/";
myrow[column[j]] = dr[column[j]];
}
else
{
if (Convert.ToString(dr[column[j]]).TrimEnd() == " ")
{
myrow[column[j]] = "";
}
else
{
myrow[column[j]] = dr[column[j]];
}
}
if (column[j] == "Stock" || column[j] == "QtyInStock" || column[j] == "Qty" || column[j] == "Available" || column[j].ToLower() == "onhand" || column[j] == "QuantityOnHand" || column[j] == "QtyAvailable" || column[j] == "InStock" || column[j] == "Avail" || column[j] == "Inventory" || column[j] == "Quantity" || column[j] == "Availability")
{
if (Convert.ToString(dr[column[j]]) != "0" && Convert.ToString(dr[column[j]]) != "" && dr[column[j]] != null && Convert.ToString(dr[column[j]]).TrimEnd()!=" ")
{
stock = dr[column[j]].ToString();
}
}
}
}
k++;
dt.Rows.Add(myrow);
}
#endregion
column = null;
return dt;
}
Then i adding to a div everytime like:
mydiv.Controls.Add(grdnew);
as above i repeate the loop for different table of data to bind to gridview.Here i need a link button to gridview.so i added a hyperlink column to datatable,but i'm not getting any linkbutton in grid.I have more than 20 tables of data to bind to grid.so i preferred to create the grid dynamically.
Just replace the grid with datagrid and add hyperlinkcolumn to datatable and give data to that column as click me
DataTable dt=new DataTable();
HyperLinkColumn hplink = new HyperLinkColumn();
hplink.Text = column1[i];
dt.Columns.Add(hplink.Text);
DataRow myrow = dt.NewRow();
myrow[column1[l]] = String.Format("<a href='" + imageUrl(gettablename(tablename)) + "' target='_blank'>" + dr[column[j]] + "</a>");
dt.Rows.Add(myrow);
DataGrid1.DataSource=dt;
DataGrid1.DataBind();
Thats it problem solved.
TableCell tc1 = new TableCell();
tc1.Wrap=true;
this.lnkRecvGpNo=new LinkButton();
lnkRecvGpNo.Text="RecvGp No";
this.lnkRecvGpNo.Click+=new EventHandler(lnkRecvGpNo_Click);
tc1.Controls.Add(lnkRecvGpNo);

Resources