jQuery JSON,ASP.NET与SQL数据库:id与数据提取过程

时间:2016-08-21 11:46:21

标签: c# jquery asp.net json ajax

jQuery JSON ASP.NET在数据表中省略了用C#打印的数据。

我想做的是过程:

image

代码:

function DetayGetir(ID) {

    $.ajax({
        type: "POST",
        url: "KiralikDaireListesi/DetayGetir",
        data: "{ID:'" + ID + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: " json",
        success: function (msg) {
            alert();
        }
    });
}

cs c#

//[WebMethod]
//public static string GetIDPDetails(int xIDPID)
//{
//    SqlConnection baglanti = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["EmlakTakip"].ConnectionString);

//    string jsonString = "{}";
//    using (SqlDataAdapter adp = new SqlDataAdapter())
//    {
//        using (SqlCommand cmd = new SqlCommand("KiralikDaire", baglanti))
//        {
//            cmd.CommandType = CommandType.StoredProcedure;
//            cmd.Parameters["@ID"].Value = xIDPID;
//            adp.SelectCommand = cmd;
//            DataSet oDs = new DataSet();
//            adp.Fill(oDs);
//            jsonString = JsonConvert.SerializeObject(oDs, Formatting.Indented);

//        }
//    }
//    return jsonString;
//}

ASP

 <asp:Repeater ID="kiraliklarList" runat="server">
     <HeaderTemplate>
         <table id="example" class="table dt-responsive table-hover" cellspacing="0" width="100%">
             <thead>
                 <tr>
                     <th>Kayıt No</th>
                     <th>Adı</th>
                     <th>Soyadı</th>
                     <th>Telefon</th>
                     <th>MetreKare</th>
                     <th>Isıtma</th>
                     <th>Fiyat</th>
                     <th>Mahalle</th>
                     <th>&nbsp;</th>
                     <th class="hidden-lg">&nbsp;</th>
                 </tr>
             </thead>
             <tbody>
     </HeaderTemplate>
     <ItemTemplate>
                 <tr onclick="KDLdetay(<%#DataBinder.Eval(Container,"DataItem.ID")%>)">
                     <td><%# Eval("ID") %></td>
                     <td><%# Eval("adi") %></td>
                     <td><%# Eval("soyadi") %></td>
                     <td><%# Eval("Telefon") %></td>
                     <td><%# Eval("m2") %></td>
                     <td><%# Eval("isitma") %></td>
                     <td><%# Eval("fiyat") %></td>
                     <td><%# Eval("Mahalle") %></td>
                     <td class="waves-effect">
                         <a href="KiralikDaireler.aspx?ID=<%#DataBinder.Eval(Container,"DataItem.ID")%>"><i class="tableSearch zmdi zmdi-search"></i></a>
                         <%--<asp:LinkButton runat="server" ID="btnGoster" type="button" ClientIDMode="Static" class="btn btn-flat IdAlma waves-effect"><i class="tableSearch zmdi zmdi-search"></i></asp:LinkButton>--%>
                         <%--<a href="#" onclick="btnGoster"  class="btn-flat IdAlma"><i class="tableSearch zmdi zmdi-search"></i></a>--%>
                         <%--<asp:LinkButton runat="server"  ID="almaid" OnClientClick='<%# Eval("ID", "OpenPopup({0});") %>'><i class="tableSearch zmdi zmdi-search"></i></asp:LinkButton>--%>

                         <%--<asp:Label runat="server" ID="IDalma" Text='<%#DataBinder.Eval(Container,"DataItem.ID")%>'></asp:Label>--%>
                         <%--<button type="button" runat="server" id="gosterBtn"><i class="tableSearch zmdi zmdi-search"></i><%#DataBinder.Eval(Container,"DataItem.ID")%></button>--%>
                         <%--<asp:LinkButton runat="server" ID="gosterBtn"><i class="tableSearch zmdi zmdi-search"></i></asp:LinkButton>--%>
                     </td>
                     <td class="waves-effect hidden-lg"><a href="#!" class="AyrintiGoster"><i class="zmdi zmdi-info-outline grey-text fa-2x"></i></a></td>
                 </tr>
     </ItemTemplate>
     <FooterTemplate>
             </tbody>
         </table>
     </FooterTemplate>
 </asp:Repeater>

HTML

////  ////  the field I want to show you

<div class="col-md-6 col-lg-3 col-xs-12 col-sag">
                    <div class="HeaderSagBolum">
                    </div>
                    <div class="ListelemeSagBolum">
                        <div class="statusImages">
                            <a href="#"><i class="mhc-cdefault mcc-primary zmdi zmdi-info-outline fa-4x" aria-hidden="true"></i></a>
                        </div>
                        <div class="ListelemeSagBolumText">
                            <p class="infoListeleme">Information<span class="hidden"> - <a href="#"><span class="mcc-default-imp"></span></a></span></p>
                            <div id="infobos" class="listelemeSagLineHeight hidden">
                                <p class="tableBaslik">For Quick Review</p>
                                <p><i class="fa fa-arrow-left" aria-hidden="true"></i>&nbsp;Click on the records of the table</p>
                            </div>
                            <div id="infodolu" class="">
                                <p class="tableBaslik">Adı</p>
                                <p id="adi"></p>
                                <p class="tableBaslik">Soyadı</p>
                                <p id="soyadi"></p>
                                <p class="tableBaslik">Telefon</p>
                                <p id="telefon"></p>
                                <p class="tableBaslik">m2</p>
                                <p id="m2"></p>
                                <p class="tableBaslik">Isıtma</p>
                                <p id="isitma"></p>
                                <p class="tableBaslik">Fiyat</p>
                                <p id="fiyat"></p>
                                <p class="tableBaslik">Mahalle</p>
                                <p id="mahalle"></p>
                                <br />
                                <input id="hfCTID" type="hidden" />
                                <br />
                                <br />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

0 个答案:

没有答案