自定义Html控制Ajax更新

时间:2012-10-26 05:26:51

标签: ajax asp.net-mvc

我有自定义网格控件,当我们提供coloumn和表名时,其中有一个搜索功能也可用,它更新记录并在搜索ajax时显示网格中的更新结果我正在获取记录更新但未显示在主页

        SqlParameter[] sqlParameter = {new SqlParameter("@table",tabelName),
                                      new SqlParameter("@Column1",coloumn1),
                                      new SqlParameter ("@Column2",coloumn2),
                                      new SqlParameter("@AliasName1",aliasName1),
                                      new SqlParameter("@AliasName2",aliasName2)

                                      };

        string gridHtml;
        if (!isFilterCondition)
        {
             gridHtml = GenerateHtmlGrid(sqlParameter);
        }
        else
        {
            gridHtml = GenerateHtmlGridonSearch();
        }
        StringBuilder sb = new StringBuilder();
        //Opening For Main page Search Control
        sb.AppendFormat("<table>");
        sb.AppendFormat("<tr><td>");
        sb.AppendFormat("<input id='txt_Search' type='text'  name='txt_Search'>");
        sb.AppendFormat("<input type='hidden' name='{0}' class='WorkItem'>", controlName);
        sb.AppendFormat("</td><td>");
        sb.AppendFormat("<a href='#' id='searchlink'><img src='../../Content/themes/base/images/16px-Searchtool_right.png' /></a>");
        sb.AppendFormat("</td></tr></table>");
        //Closing For Main page Search Control

        // Opening for the Dialog Box Div
        sb.AppendFormat("<div id='dialoggrid' title='{0}' >", popWindowTitle);
        sb.AppendFormat("<table>");
        sb.AppendFormat("<tr><td></td><td>");
        sb.AppendFormat("<select name='foo' id='foo'>");
        sb.AppendFormat("<option value=0>{0}</option>", aliasName1);
        sb.AppendFormat("<option value=1>{0}</option>", aliasName2);
        sb.AppendFormat("</select>");
        sb.AppendFormat("</td></tr>");
        sb.AppendFormat("<tr><td>");
        sb.AppendFormat("<label>Search</label>");
        sb.AppendFormat("</td><td>");
        sb.AppendFormat("<input id='txtGridSearch' type='text'  name='txtGridSearch'>");
        //sb.AppendFormat("<a href='#' id='SearchTree'><img src='../../Content/themes/base/images/16px-Searchtool_right.png' /></a>");
        sb.AppendFormat("</table>");

        sb.AppendFormat("<div id='div_grid'>{0}</div>", gridHtml);
        sb.AppendFormat("</div>");
        // Closing  for the Dialog Box Div

        //opening For Script Section 
        sb.AppendFormat("<script type='text/javascript'>");

        //Opening for Document Reddy
        sb.AppendFormat("$(document).ready(function() {{ ");
        sb.AppendFormat("$('#dialoggrid').dialog({{ autoOpen: false,modal: true,width: 350}});");
        //Function For SearchButton on Main Page Click 
        sb.AppendFormat("$('#searchlink').click(function() {{");
        sb.AppendFormat("$( '#dialoggrid').dialog('open');");
        sb.AppendFormat("}});");
        //Closing For SearchButton on Main Page Click 

        //opening For Textbox Search inside the Grid on Key Up Event
        sb.AppendFormat("$('#txtGridSearch').keyup(function(){{");
        sb.AppendFormat("$.post('/CustomeControls/GridSearch')");


        sb.AppendFormat("}});");
        //Closeing For Textbox Search inside the Grid on Key Up Event

        sb.AppendFormat("}});");
        //Closing For Document Reddy Function 

        sb.AppendFormat("</script>");
        //Closing for Script Section 


        return new MvcHtmlString(sb.ToString());
    }

0 个答案:

没有答案