Sheetal Inani
Sheetal Inani

Reputation: 128

set position of grid view at runtime in asp.net

I want to show a grid in center on pageload and when I click on select button on grid it should shift to right of page....

Currently, I am using 2 grid's to show it on center and on right...

Upvotes: 0

Views: 4239

Answers (2)

Sheetal Inani
Sheetal Inani

Reputation: 128

if grid is present in div give id and property runat=server then on select button give this coding... griddiv.Style.Add("float","right");

Upvotes: 0

KhanZeeshan
KhanZeeshan

Reputation: 1410

To change position from server side:

if grid is present in DIV or any other HTML tag add runat="sever" to that then after button is pressed access the style property of that div & get the Left or Right or Top or any other position-attribute assign the desired position to that attribute & update the updatepanel in which that div is present.

<Markup>
<asp:updatepanel id="up1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="griddiv" runat="server">
<asp:grid id="maingrid" runat="server"/>
</div>
</ContentTemplate>
</asp:updatepane>


protected void btn_Click(object sender,Eventargs es)
{

griddiv.style.attribute("top","new pos");
//This is done as a precaution
maingrid.DataSource = datatable;
maingrid.Rebind();
up1.Update();
}

Upvotes: 1

Related Questions