简体   繁体   中英

How to refresh gridview when I use sqldatasource in asp.net

I am developing an asp.net website .this web site is multilangual. some section of this website is static and some of them are dynamic and get their data from database.so in this project I have a master page and i have default page which is filled with a gridview that is feed by a sqldatasource.so when I change language to english I want gridview to refresh and retrive english data from database and display in gridview .i dont know how to do this please help me

 string language = "fa-IR";
        Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
        HttpCookie LangCookies = new HttpCookie("Language");
        LangCookies.Value = language;
        LangCookies.Expires = DateTime.Now.AddHours(1);
        Response.Cookies.Add(LangCookies);


<li style="text-align:center; width:130px;vertical-align:top">
                    <div>
                        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">فارسی</asp:LinkButton></div>
                    <div>
                        <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">ENG</asp:LinkButton></div>
                </li>

I don't see any code , so I'll tell you theoretically how it can be perform.

You need minimum two page for this

1)Main page

<div id="#gridview-div">
//here render your partial page
</div>

2) Partial page

<table id="gridview">
</table>

Then using ajax you should make call to server that will give you back data(Partial view) and than place this data to your gridview-div.Here is some example how to pass data into div jQuery html() Method

由于更改语言只会更改列名称或标题,因此您可以将表格中具有相应语言的网格列的所有名称或标题存储在表中,以便您可以建立多语言网站

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM