Yazılım.
CevapSitesi.com Beta!
Çözüm Noktası
Facebook, Twitter, Google+ veya e-posta ile paylaşın.
| Sorular | Makaleler | Üyeler | Etiketler  | İletişim
Soru sormak ya da cevap vermek için;
giriş yapın veya üye olun.

Sosyal medya hesaplarınızla da giriş yapabilirsiniz.

Cevap Geçmişi

13.03.19 14:26
örneği excute ettiğimdede çalıştırdığımda sayfayı aşağıdaki hatayı veriyor Server Error in '/' Application. Object cannot be cast from DBNull to other types. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types. Source Error: Line 93: idr.Close(); Line 94: con.Close(); Line 95: int recordCount = Convert.ToInt32(cmd.Parameters["@RecordCount"].Value); Line 96: //Sayfalama rptr hazırlanıyor Line 97: this.PopulatePager(recordCount, pageIndex); Source File: c:\Users\aek\Desktop\hanedandekor\Yeni klasör\hd\Default.aspx.cs    Line: 95  Hataceriyor hocam. Olmuyor İlgini için teşekkürler hocam gerçekten hakkınızı ödeyemen ama hala yapamadım yardımınızla yapacağımı umuyorum. hata alıyorum hala Buda Default.aspx.cs kodum using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient; using System.Web.UI; using System.Web.UI.WebControls; using System.Configuration; public partial class Default : System.Web.UI.Page { private SqlHelper helper = new SqlHelper(); Fonksiyon f = new Fonksiyon(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.GetCustomersPageWise(1,0,"asc"); } DataTable dt = f.GetDataTable("select UrunUstKategoriId,UrunUstKategoriAdi from UrunUstKategoriler order by UrunUstKategoriAdi asc "); MyKategoriRpt.DataSource = dt; MyKategoriRpt.DataBind(); } #region Sayfalama //Bir sayfada gösterilecek ürün sayısını yazıyorum private int PageSize = 9; //Sayfa değiştikçe sayfanın numarasını alan fonksiyon int currentPageIndex = 1; protected void Page_Changed(object sender, EventArgs e) { int pageIndex = int.Parse((sender as LinkButton).CommandArgument); int orderby = 1; string asc = "asc"; switch (ddlSorting.SelectedValue) { //Eklenme sırasına göre case "0": orderby = 0; asc = "asc"; break; case "1": orderby = 1; asc = "asc"; break; case "2": orderby = 1; asc = "desc"; break; case "3": orderby = 2; asc = "asc"; break; case "4": orderby = 2; asc = "desc"; break; } currentPageIndex = pageIndex; GetCustomersPageWise(pageIndex, orderby, asc); } //ürünleri veritabanından stored procedure ile çağıran kodlar private void GetCustomersPageWise(int pageIndex,int orderby, string asc) { string constring = ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString; using (SqlConnection con = new SqlConnection(constring)) { using (SqlCommand cmd = new SqlCommand("GetCustomersPageWise", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PageIndex", pageIndex); cmd.Parameters.AddWithValue("@PageSize", PageSize); //order by için 2 yazarsanız fiyata göre, 1 yazarsanız ada göre sıralar cmd.Parameters.AddWithValue("@orderColumn", orderby); //asc için asc yazarsanız a-z sıralar desc yazarsanız z-a sıralar cmd.Parameters.AddWithValue("@orderdir", asc); //Burada kayıt sayısını parametre olarak dışarı aldık cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4); cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output; con.Open(); IDataReader idr = cmd.ExecuteReader(); RpUrun.DataSource = idr; RpUrun.DataBind(); idr.Close(); con.Close(); int recordCount = Convert.ToInt32(cmd.Parameters["@RecordCount"].Value); //Sayfalama rptr hazırlanıyor this.PopulatePager(recordCount, pageIndex); } } } //Sayfalama için gerekli kod private void PopulatePager(int recordCount, int currentPage) { //Sayfa sayısını bulduk double dblPageCount = (double)((decimal)recordCount / Convert.ToDecimal(PageSize)); int pageCount = (int)Math.Ceiling(dblPageCount); List<ListItem> pages = new List<ListItem>(); if (pageCount > 0) { for (int i = 1; i <= pageCount; i++) { //Sayfaları listeye ekliyoruz pages.Add(new ListItem(i.ToString(), i.ToString(), i != currentPage)); } } rptPager.DataSource = pages; rptPager.DataBind(); rptPager2.DataSource = pages; rptPager2.DataBind(); } #endregion protected void ilkRepeaterYulendiginde(object senger, RepeaterItemEventArgs e) { string KategoriID = (e.Item.FindControl("KategoriIDHF") as HiddenField).Value; SqlConnection baglan = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString); SqlDataAdapter ad = new SqlDataAdapter("select UrunKategoriId,UrunKategoriAdi from UrunKategoriler where UrunUstKategoriId=@UrunUstKategoriId order by UrunKategoriAdi asc", baglan); ad.SelectCommand.Parameters.AddWithValue("@UrunUstKategoriId", SqlDbType.Int).Value = int.Parse(KategoriID); DataSet ds = new DataSet(); ad.Fill(ds); Repeater Rpt = (e.Item.FindControl("sayfalarRpt") as Repeater); int kacsatir = ds.Tables[0].Rows.Count; if (kacsatir != 1) { Rpt.DataSource = ds; Rpt.DataBind(); } else { HyperLink hp = (e.Item.FindControl("BenimUrl") as HyperLink); hp.NavigateUrl = "urunkategori_"+Ayarlar.UrlSeo(ds.Tables[0].Rows[0].ItemArray[1].ToString()) + "_" + ds.Tables[0].Rows[0].ItemArray[0].ToString() + ".html"; hp.Text = ds.Tables[0].Rows[0].ItemArray[1].ToString(); //foreach (DataRow s in ds.Tables[0].Rows) } baglan.Open(); } protected void ddlSorting_SelectedIndexChanged(object sender, EventArgs e) { int pageIndex=1; try { pageIndex = int.Parse((sender as LinkButton).CommandArgument); } catch (Exception) { } int orderby = 1; string asc = "asc"; switch (ddlSorting.SelectedValue) { case "0": orderby = 0; asc = "asc"; break; case "1": orderby = 1; asc = "asc"; break; case "2": orderby = 1; asc = "desc"; break; case "3": orderby = 2; asc = "asc"; break; case "4": orderby = 2; asc = "desc"; break; } GetCustomersPageWise(pageIndex, orderby, asc); } } Buda Default.aspx tarafı <%@ Page Title="" Language="C#" MasterPageFile="~/Hanedan.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <style> body, html, table { width: 100%; height: 100%; } body { margin: 0; padding: 0; } table td { vertical-align: middle; } .slideWrapper { position: relative; width: 870px; height: 350px; margin: 0 auto; } .slideWrapper img { position: absolute; top: 0; left: 0px; display: none; } .slideWrapper img:nth-child(1) { display: block; } .text-center { text-align:center; } </style> <script> var allImages; var imgCount; var current = 0; $(document).ready(function ($) { allImages = $(".slideWrapper img"); imgCount = allImages.length; setInterval(slide, 3500); }); function slide() { if (current == (imgCount - 1)) { allImages.fadeOut(600).eq(0).fadeIn(600); current = 0; } else { current++; allImages.fadeOut(600).eq(current).fadeIn(600); } } </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <!--==============================content=================================--> <div id="content"> <div class="row-title"> </div> <div class="container"> <div class="row content-div"> <article class="span9 m_top_20"> <div class="slideWrapper"> <img src="/examples/images/space1.jpg" /> <img src="/examples/images/space2.jpg" /> <img src="/examples/images/space3.jpg" /> <img src="/examples/images/space4.jpg" /> <img src="/examples/images/space5.jpg" /> <img src="/examples/images/space6.jpg" /> </div> <div class="sort_shop txt-1 clearfix no_bord m_top_20"> <div class="fleft clearfix"> <table class="description_table type_2"> <tr> <td class="v_align_m">Sıralama ölçütü:</td> <td class="v_align_m"> <div class="relative d_inline_middle"> <asp:DropDownList ID="ddlSorting" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlSorting_SelectedIndexChanged"> <asp:ListItem Value="0">Varsayılan liste</asp:ListItem> <asp:ListItem Value="1">Ürün ismi A-Z</asp:ListItem> <asp:ListItem Value="2">Ürün ismi Z-A</asp:ListItem> <asp:ListItem Value="3">Ürün fiyatı- Azdan Çoka</asp:ListItem> <asp:ListItem Value="4">Ürün fiyatı- Çoktan Aza</asp:ListItem> </asp:DropDownList> </div> </td> </tr> </table> </div> <div id="navigation" class="navigation_grid"> <span>Görünüm Modu Seçiniz:</span> <a class="active btn-tags hasTooltip Cgrid" href="#" title="" data-original-title="Katalog">Katalog<i class="fa fa-th"></i></a> <a class="btn-tags hasTooltip Clist" href="#" title="" data-original-title="Liste">Liste<i class="fa fa-th-list"></i></a> </div> </div> <div class="clearfix sort_shop txt-1"> <div class="v_block-control fright"> <div class="control-post"> <asp:Repeater ID="rptPager2" runat="server"> <ItemTemplate> <asp:LinkButton CssClass="prev-post control-btn btn-3 v_button_var" Visible='<%#Convert.ToBoolean(Container.ItemIndex == 0 ) %>' CommandArgument='<%# Eval("Value") %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>' runat="server"> <asp:PlaceHolder runat="server"> <i class="fa fa-angle-left"></i> </asp:PlaceHolder> </asp:LinkButton> <asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>' CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton> <asp:LinkButton CssClass="next-post control-btn btn-3 v_button_var" Visible='<%#Convert.ToBoolean(Container.ItemIndex == (rptPager2.DataSource as IList).Count-1) %>' CommandArgument='<%# Eval("Value") %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>' runat="server"> <asp:PlaceHolder runat="server"> <i class="fa fa-angle-right"></i> </asp:PlaceHolder> </asp:LinkButton> </ItemTemplate> </asp:Repeater> </div> </div> </div> <%--/////////////////////////////////////////////////////////////////////////////////////////////////////--%> <div id="product_list" class="m_top_10 list_grid"> <asp:Repeater ID="RpUrun" runat="server"> <ItemTemplate> <%# (Container.ItemIndex == 0 || Container.ItemIndex % 3 == 0) ? "<div class=\"poduct_wrap\"><ul class=\"row v_index\">" : string.Empty %> <li class="span3"> <div class="block-product"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower())%>_satis_<%#Eval("UrunId") %>.html"> <figure class="box-product"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower())%>_satis_<%#Eval("UrunId") %>.html" class="img-product"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower()) %>_satis_<%#Eval("UrunId") %>.html"><img src="HaberResimleri/290/<%#Eval("Resmi") %>" alt=""></a> <%#(Eval("EnCokSatanlar").ToString() == "1") ? "<span class=\"hot hot_red\">Çok Satan</span>" : string.Empty %> </a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div class="box_content"> <h5 class="product-name"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower())%>_satis_<%#Eval("UrunId") %>.html"><%#Eval("UrunAdi") %> <br /><%#Eval("StokKodu") %></a> </h5> <span class="price"><%#Eval("UrunFiyati") %>,00₺<span> </div> </figure> </a> <div class="v_space2 v_list_block"> <h5 class="m_bottom_15 txt_trans"><a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower()) %>_satis_<%#Eval("UrunId") %>.html"><%#Eval("UrunAdi") %></a></h5> <div class="m_bottom_15"> <!--rating--> <div class="v_price"><%#Eval("UrunFiyati") %>,00-&#8378;</div> <ul class="horizontal_list d_inline_middle type_2 clearfix rating_list tr_all_hover"> <li class="active"> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> <li class="active"> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> <li class="active"> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> <li class="active"> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> <li> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> </ul> <span class="txt-1 v_reviews"> <a href="#" class="d_inline_middle default_t_color f_size_small p_left_20"><%#Eval("Nekadardandustu")%></a> | <a href="#" class="d_inline_middle m_left_5">İzlenme(<%#Eval("Hit")%>)</a> </span> </div> <hr class="m_bottom_15 m_t_no_space"> <table class="description_table m_bottom_15 txt-2"> <tr> <td> <%#Eval("UrunDetay")%> </td> </tr> </table> <hr class="m_bottom_15 m_t_no_space"> <div class="m_ls_bottom_10"> <div class="d_inline_b"> <button class="btn-cart btn-small btn-blue"> <strong>Sepete Ekle</strong> </button> </div> </div> </div> <figure class="box-product-hover"> <a class="img-product"> <img src="HaberResimleri/290/<%#Eval("Resmi")%>"width="290" height="290"" alt=""/> </a> <%#(Eval("Indirimdekiler").ToString() == "1") ? "<span class=\"hot\">İndirimde!</span>" : string.Empty %> <h5 class="product-name"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower()) %>_satis_<%#Eval("UrunId") %>.html"><%#Eval("UrunAdi") %><br /><%#Eval("StokKodu") %></a> </h5> <span class="price"><%#Eval("UrunFiyati") %>,00-&#8378;</span> </figure> </div> </li> <%# (Container.ItemIndex % 3 == 2) ? " </ul></div>" : string.Empty %> </ItemTemplate> </asp:Repeater> </div><div></div> <div style="margin-top:89px;" class="clearfix sort_shop txt-1"> <div class="v_block-control fright"> <div class="control-post"> <asp:Repeater ID="rptPager" runat="server"> <ItemTemplate> <asp:LinkButton CssClass="prev-post control-btn btn-3 v_button_var" Visible='<%#Convert.ToBoolean(Container.ItemIndex == 0 ) %>' CommandArgument='<%# Eval("Value") %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>' runat="server"> <asp:PlaceHolder runat="server"> <i class="fa fa-angle-left"></i> </asp:PlaceHolder> </asp:LinkButton> <asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>' CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton> <asp:LinkButton CssClass="next-post control-btn btn-3 v_button_var" Visible='<%#Convert.ToBoolean(Container.ItemIndex == (rptPager.DataSource as IList).Count-1) %>' CommandArgument='<%# Eval("Value") %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>' runat="server"> <asp:PlaceHolder runat="server"> <i class="fa fa-angle-right"></i> </asp:PlaceHolder> </asp:LinkButton> </ItemTemplate> </asp:Repeater> </div> </div> </div> </article> <article class="span3"> <div class="col-left"> <!-- block-widget --> <div class="block-widget v_space category" id="Mod123"> <h4 class="heading-h4 m_bottom_15">ÜRÜNLER</h4> <div class="module-ct"> <ul id="accordion" class="list"> <asp:Repeater ID="MyKategoriRpt" runat="server" EnableTheming="True" OnItemDataBound="ilkRepeaterYulendiginde"> <ItemTemplate> <asp:HiddenField ID="KategoriIDHF" runat="server" Value='<%#Eval("UrunUstKategoriId") %>'/> <li class="level0 VmClose parent"> <a class="screenshot" href="/reviver/images/stories/virtuemart/category/resized/cat02_resized.jpg" title=""> <asp:HyperLink runat="server" ID="BenimUrl" NavigateUrl='<%#"urunustkategori_"+Ayarlar.UrlSeo(Eval("urunustkategoriadi").ToString())+"_"+Eval("urunustkategoriId") +".html"%>' Text='<%#Eval("urunustkategoriAdi") %>'></asp:HyperLink></a> <span class="VmArrowdown idCatSubcat close collapsed button_type_11 bg_light_color_1 t_align_c f_size_ex_large bg_cs_hover r_corners d_inline_middle bg_tr tr_all_hover qv_btn_single_prev"><i class="fa fa-angle-down"></i></span> <ul class="level1"<%-- style="display: block!important;"--%>> <asp:Repeater ID="sayfalarRpt" runat="server"> <ItemTemplate> <li class="level1 VmClose firstItem"> <a class="screenshot" href="<%#"urunkategori_"+Ayarlar.UrlSeo(Eval("UrunKategoriAdi").ToString())+"_"+Eval("UrunKategoriId") +".html"%>" rel="/reviver/images/stories/virtuemart/category/resized/cat27_resized.jpg "> <%#Eval("UrunKategoriAdi") %> </a> </li> </ItemTemplate> </asp:Repeater> </ul> </li> </ItemTemplate> </asp:Repeater> </ul> </div> </div> <!-- end block-widget --> </div> </article> </div> </div> </div> </asp:Content>
Ekleyen: hanzalar
Değiştiren: cevapsitesi
15.12.16 21:12
örneği excute ettiğimdede çalıştırdığımda sayfayı aşağıdaki hatayı veriyor Server Error in '/' Application. Object cannot be cast from DBNull to other types. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types. Source Error: Line 93: idr.Close(); Line 94: con.Close(); Line 95: int recordCount = Convert.ToInt32(cmd.Parameters["@RecordCount"].Value); Line 96: //Sayfalama rptr hazırlanıyor Line 97: this.PopulatePager(recordCount, pageIndex); Source File: c:\Users\aek\Desktop\hanedandekor\Yeni klasör\hd\Default.aspx.cs    Line: 95  Hataceriyor hocam. Olmuyor İlgini için teşekkürler hocam gerçekten hakkınızı ödeyemen ama hala yapamadım yardımınızla yapacağımı umuyorum. hata alıyorum hala Buda Default.aspx.cs kodum using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient; using System.Web.UI; using System.Web.UI.WebControls; using System.Configuration; public partial class Default : System.Web.UI.Page { private SqlHelper helper = new SqlHelper(); Fonksiyon f = new Fonksiyon(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.GetCustomersPageWise(1,0,"asc"); } DataTable dt = f.GetDataTable("select UrunUstKategoriId,UrunUstKategoriAdi from UrunUstKategoriler order by UrunUstKategoriAdi asc "); MyKategoriRpt.DataSource = dt; MyKategoriRpt.DataBind(); } #region Sayfalama //Bir sayfada gösterilecek ürün sayısını yazıyorum private int PageSize = 9; //Sayfa değiştikçe sayfanın numarasını alan fonksiyon int currentPageIndex = 1; protected void Page_Changed(object sender, EventArgs e) { int pageIndex = int.Parse((sender as LinkButton).CommandArgument); int orderby = 1; string asc = "asc"; switch (ddlSorting.SelectedValue) { //Eklenme sırasına göre case "0": orderby = 0; asc = "asc"; break; case "1": orderby = 1; asc = "asc"; break; case "2": orderby = 1; asc = "desc"; break; case "3": orderby = 2; asc = "asc"; break; case "4": orderby = 2; asc = "desc"; break; } currentPageIndex = pageIndex; GetCustomersPageWise(pageIndex, orderby, asc); } //ürünleri veritabanından stored procedure ile çağıran kodlar private void GetCustomersPageWise(int pageIndex,int orderby, string asc) { string constring = ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString; using (SqlConnection con = new SqlConnection(constring)) { using (SqlCommand cmd = new SqlCommand("GetCustomersPageWise", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PageIndex", pageIndex); cmd.Parameters.AddWithValue("@PageSize", PageSize); //order by için 2 yazarsanız fiyata göre, 1 yazarsanız ada göre sıralar cmd.Parameters.AddWithValue("@orderColumn", orderby); //asc için asc yazarsanız a-z sıralar desc yazarsanız z-a sıralar cmd.Parameters.AddWithValue("@orderdir", asc); //Burada kayıt sayısını parametre olarak dışarı aldık cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4); cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output; con.Open(); IDataReader idr = cmd.ExecuteReader(); RpUrun.DataSource = idr; RpUrun.DataBind(); idr.Close(); con.Close(); int recordCount = Convert.ToInt32(cmd.Parameters["@RecordCount"].Value); //Sayfalama rptr hazırlanıyor this.PopulatePager(recordCount, pageIndex); } } } //Sayfalama için gerekli kod private void PopulatePager(int recordCount, int currentPage) { //Sayfa sayısını bulduk double dblPageCount = (double)((decimal)recordCount / Convert.ToDecimal(PageSize)); int pageCount = (int)Math.Ceiling(dblPageCount); List<ListItem> pages = new List<ListItem>(); if (pageCount > 0) { for (int i = 1; i <= pageCount; i++) { //Sayfaları listeye ekliyoruz pages.Add(new ListItem(i.ToString(), i.ToString(), i != currentPage)); } } rptPager.DataSource = pages; rptPager.DataBind(); rptPager2.DataSource = pages; rptPager2.DataBind(); } #endregion protected void ilkRepeaterYulendiginde(object senger, RepeaterItemEventArgs e) { string KategoriID = (e.Item.FindControl("KategoriIDHF") as HiddenField).Value; SqlConnection baglan = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString); SqlDataAdapter ad = new SqlDataAdapter("select UrunKategoriId,UrunKategoriAdi from UrunKategoriler where UrunUstKategoriId=@UrunUstKategoriId order by UrunKategoriAdi asc", baglan); ad.SelectCommand.Parameters.AddWithValue("@UrunUstKategoriId", SqlDbType.Int).Value = int.Parse(KategoriID); DataSet ds = new DataSet(); ad.Fill(ds); Repeater Rpt = (e.Item.FindControl("sayfalarRpt") as Repeater); int kacsatir = ds.Tables[0].Rows.Count; if (kacsatir != 1) { Rpt.DataSource = ds; Rpt.DataBind(); } else { HyperLink hp = (e.Item.FindControl("BenimUrl") as HyperLink); hp.NavigateUrl = "urunkategori_"+Ayarlar.UrlSeo(ds.Tables[0].Rows[0].ItemArray[1].ToString()) + "_" + ds.Tables[0].Rows[0].ItemArray[0].ToString() + ".html"; hp.Text = ds.Tables[0].Rows[0].ItemArray[1].ToString(); //foreach (DataRow s in ds.Tables[0].Rows) } baglan.Open(); } protected void ddlSorting_SelectedIndexChanged(object sender, EventArgs e) { int pageIndex=1; try { pageIndex = int.Parse((sender as LinkButton).CommandArgument); } catch (Exception) { } int orderby = 1; string asc = "asc"; switch (ddlSorting.SelectedValue) { case "0": orderby = 0; asc = "asc"; break; case "1": orderby = 1; asc = "asc"; break; case "2": orderby = 1; asc = "desc"; break; case "3": orderby = 2; asc = "asc"; break; case "4": orderby = 2; asc = "desc"; break; } GetCustomersPageWise(pageIndex, orderby, asc); } } Buda Default.aspx tarafı <%@ Page Title="" Language="C#" MasterPageFile="~/Hanedan.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <style> body, html, table { width: 100%; height: 100%; } body { margin: 0; padding: 0; } table td { vertical-align: middle; } .slideWrapper { position: relative; width: 870px; height: 350px; margin: 0 auto; } .slideWrapper img { position: absolute; top: 0; left: 0px; display: none; } .slideWrapper img:nth-child(1) { display: block; } .text-center { text-align:center; } </style> <script> var allImages; var imgCount; var current = 0; $(document).ready(function ($) { allImages = $(".slideWrapper img"); imgCount = allImages.length; setInterval(slide, 3500); }); function slide() { if (current == (imgCount - 1)) { allImages.fadeOut(600).eq(0).fadeIn(600); current = 0; } else { current++; allImages.fadeOut(600).eq(current).fadeIn(600); } } </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <!--==============================content=================================--> <div id="content"> <div class="row-title"> </div> <div class="container"> <div class="row content-div"> <article class="span9 m_top_20"> <div class="slideWrapper"> <img src="/examples/images/space1.jpg" /> <img src="/examples/images/space2.jpg" /> <img src="/examples/images/space3.jpg" /> <img src="/examples/images/space4.jpg" /> <img src="/examples/images/space5.jpg" /> <img src="/examples/images/space6.jpg" /> </div> <div class="sort_shop txt-1 clearfix no_bord m_top_20"> <div class="fleft clearfix"> <table class="description_table type_2"> <tr> <td class="v_align_m">Sıralama ölçütü:</td> <td class="v_align_m"> <div class="relative d_inline_middle"> <asp:DropDownList ID="ddlSorting" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlSorting_SelectedIndexChanged"> <asp:ListItem Value="0">Varsayılan liste</asp:ListItem> <asp:ListItem Value="1">Ürün ismi A-Z</asp:ListItem> <asp:ListItem Value="2">Ürün ismi Z-A</asp:ListItem> <asp:ListItem Value="3">Ürün fiyatı- Azdan Çoka</asp:ListItem> <asp:ListItem Value="4">Ürün fiyatı- Çoktan Aza</asp:ListItem> </asp:DropDownList> </div> </td> </tr> </table> </div> <div id="navigation" class="navigation_grid"> <span>Görünüm Modu Seçiniz:</span> <a class="active btn-tags hasTooltip Cgrid" href="#" title="" data-original-title="Katalog">Katalog<i class="fa fa-th"></i></a> <a class="btn-tags hasTooltip Clist" href="#" title="" data-original-title="Liste">Liste<i class="fa fa-th-list"></i></a> </div> </div> <div class="clearfix sort_shop txt-1"> <div class="v_block-control fright"> <div class="control-post"> <asp:Repeater ID="rptPager2" runat="server"> <ItemTemplate> <asp:LinkButton CssClass="prev-post control-btn btn-3 v_button_var" Visible='<%#Convert.ToBoolean(Container.ItemIndex == 0 ) %>' CommandArgument='<%# Eval("Value") %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>' runat="server"> <asp:PlaceHolder runat="server"> <i class="fa fa-angle-left"></i> </asp:PlaceHolder> </asp:LinkButton> <asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>' CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton> <asp:LinkButton CssClass="next-post control-btn btn-3 v_button_var" Visible='<%#Convert.ToBoolean(Container.ItemIndex == (rptPager2.DataSource as IList).Count-1) %>' CommandArgument='<%# Eval("Value") %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>' runat="server"> <asp:PlaceHolder runat="server"> <i class="fa fa-angle-right"></i> </asp:PlaceHolder> </asp:LinkButton> </ItemTemplate> </asp:Repeater> </div> </div> </div> <%--/////////////////////////////////////////////////////////////////////////////////////////////////////--%> <div id="product_list" class="m_top_10 list_grid"> <asp:Repeater ID="RpUrun" runat="server"> <ItemTemplate> <%# (Container.ItemIndex == 0 || Container.ItemIndex % 3 == 0) ? "<div class=\"poduct_wrap\"><ul class=\"row v_index\">" : string.Empty %> <li class="span3"> <div class="block-product"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower())%>_satis_<%#Eval("UrunId") %>.html"> <figure class="box-product"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower())%>_satis_<%#Eval("UrunId") %>.html" class="img-product"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower()) %>_satis_<%#Eval("UrunId") %>.html"><img src="HaberResimleri/290/<%#Eval("Resmi") %>" alt=""></a> <%#(Eval("EnCokSatanlar").ToString() == "1") ? "<span class=\"hot hot_red\">Çok Satan</span>" : string.Empty %> </a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div class="box_content"> <h5 class="product-name"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower())%>_satis_<%#Eval("UrunId") %>.html"><%#Eval("UrunAdi") %> <br /><%#Eval("StokKodu") %></a> </h5> <span class="price"><%#Eval("UrunFiyati") %>,00₺<span> </div> </figure> </a> <div class="v_space2 v_list_block"> <h5 class="m_bottom_15 txt_trans"><a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower()) %>_satis_<%#Eval("UrunId") %>.html"><%#Eval("UrunAdi") %></a></h5> <div class="m_bottom_15"> <!--rating--> <div class="v_price"><%#Eval("UrunFiyati") %>,00-&#8378;</div> <ul class="horizontal_list d_inline_middle type_2 clearfix rating_list tr_all_hover"> <li class="active"> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> <li class="active"> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> <li class="active"> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> <li class="active"> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> <li> <i class="fa fa-star empty tr_all_hover"></i> <i class="fa fa-star active tr_all_hover"></i> </li> </ul> <span class="txt-1 v_reviews"> <a href="#" class="d_inline_middle default_t_color f_size_small p_left_20"><%#Eval("Nekadardandustu")%></a> | <a href="#" class="d_inline_middle m_left_5">İzlenme(<%#Eval("Hit")%>)</a> </span> </div> <hr class="m_bottom_15 m_t_no_space"> <table class="description_table m_bottom_15 txt-2"> <tr> <td> <%#Eval("UrunDetay")%> </td> </tr> </table> <hr class="m_bottom_15 m_t_no_space"> <div class="m_ls_bottom_10"> <div class="d_inline_b"> <button class="btn-cart btn-small btn-blue"> <strong>Sepete Ekle</strong> </button> </div> </div> </div> <figure class="box-product-hover"> <a class="img-product"> <img src="HaberResimleri/290/<%#Eval("Resmi")%>"width="290" height="290"" alt=""/> </a> <%#(Eval("Indirimdekiler").ToString() == "1") ? "<span class=\"hot\">İndirimde!</span>" : string.Empty %> <h5 class="product-name"> <a href="<%#Ayarlar.UrlSeo(Eval("UrunAdi").ToString().ToLower()) %>_satis_<%#Eval("UrunId") %>.html"><%#Eval("UrunAdi") %><br /><%#Eval("StokKodu") %></a> </h5> <span class="price"><%#Eval("UrunFiyati") %>,00-&#8378;</span> </figure> </div> </li> <%# (Container.ItemIndex % 3 == 2) ? " </ul></div>" : string.Empty %> </ItemTemplate> </asp:Repeater> </div><div></div> <div style="margin-top:89px;" class="clearfix sort_shop txt-1"> <div class="v_block-control fright"> <div class="control-post"> <asp:Repeater ID="rptPager" runat="server"> <ItemTemplate> <asp:LinkButton CssClass="prev-post control-btn btn-3 v_button_var" Visible='<%#Convert.ToBoolean(Container.ItemIndex == 0 ) %>' CommandArgument='<%# Eval("Value") %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>' runat="server"> <asp:PlaceHolder runat="server"> <i class="fa fa-angle-left"></i> </asp:PlaceHolder> </asp:LinkButton> <asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>' CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton> <asp:LinkButton CssClass="next-post control-btn btn-3 v_button_var" Visible='<%#Convert.ToBoolean(Container.ItemIndex == (rptPager.DataSource as IList).Count-1) %>' CommandArgument='<%# Eval("Value") %>' OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>' runat="server"> <asp:PlaceHolder runat="server"> <i class="fa fa-angle-right"></i> </asp:PlaceHolder> </asp:LinkButton> </ItemTemplate> </asp:Repeater> </div> </div> </div> </article> <article class="span3"> <div class="col-left"> <!-- block-widget --> <div class="block-widget v_space category" id="Mod123"> <h4 class="heading-h4 m_bottom_15">ÜRÜNLER</h4> <div class="module-ct"> <ul id="accordion" class="list"> <asp:Repeater ID="MyKategoriRpt" runat="server" EnableTheming="True" OnItemDataBound="ilkRepeaterYulendiginde"> <ItemTemplate> <asp:HiddenField ID="KategoriIDHF" runat="server" Value='<%#Eval("UrunUstKategoriId") %>'/> <li class="level0 VmClose parent"> <a class="screenshot" href="/reviver/images/stories/virtuemart/category/resized/cat02_resized.jpg" title=""> <asp:HyperLink runat="server" ID="BenimUrl" NavigateUrl='<%#"urunustkategori_"+Ayarlar.UrlSeo(Eval("urunustkategoriadi").ToString())+"_"+Eval("urunustkategoriId") +".html"%>' Text='<%#Eval("urunustkategoriAdi") %>'></asp:HyperLink></a> <span class="VmArrowdown idCatSubcat close collapsed button_type_11 bg_light_color_1 t_align_c f_size_ex_large bg_cs_hover r_corners d_inline_middle bg_tr tr_all_hover qv_btn_single_prev"><i class="fa fa-angle-down"></i></span> <ul class="level1"<%-- style="display: block!important;"--%>> <asp:Repeater ID="sayfalarRpt" runat="server"> <ItemTemplate> <li class="level1 VmClose firstItem"> <a class="screenshot" href="<%#"urunkategori_"+Ayarlar.UrlSeo(Eval("UrunKategoriAdi").ToString())+"_"+Eval("UrunKategoriId") +".html"%>" rel="/reviver/images/stories/virtuemart/category/resized/cat27_resized.jpg "> <%#Eval("UrunKategoriAdi") %> </a> </li> </ItemTemplate> </asp:Repeater> </ul> </li> </ItemTemplate> </asp:Repeater> </ul> </div> </div> <!-- end block-widget --> </div> </article> </div> </div> </div> </asp:Content>
Ekleyen: hanzalar
Değiştiren: cevapsitesi
15.12.16 16:10
örneği excute ettiğimdede çalıştırdığımda sayfayı aşağıdaki hatayı veriyor Server Error in '/' Application. Object cannot be cast from DBNull to other types. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types. Source Error: Line 93: idr.Close(); Line 94: con.Close(); Line 95: int recordCount = Convert.ToInt32(cmd.Parameters["@RecordCount"].Value); Line 96: //Sayfalama rptr hazırlanıyor Line 97: this.PopulatePager(recordCount, pageIndex); Source File: c:\Users\aek\Desktop\hanedandekor\Yeni klasör\hd\Default.aspx.cs    Line: 95 
Ekleyen: hanzalar

En fazla 3 eski durum gösterilir.