Home

DevExpress GridView Column Button And Popup

Just an example as a starter for 10...

Page Side...

    <dx:ASPxGridView ID="MyGrid" runat="server" OnDataBinding="MyGrid_DataBinding">
        <Columns>
            <dx:GridViewDataTextColumn FieldName="uidf" Caption="ID"></dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="emailf" Caption="Email"></dx:GridViewDataTextColumn>
            <dx:GridViewDataColumn>
                <DataItemTemplate>
                    <dx:ASPxButton ID="ShowMe" OnClick="ShowMe_Click" CommandArgument='<%# Eval("uidf") %>' Text="Show Me" runat="server"></dx:ASPxButton>
                </DataItemTemplate>
            </dx:GridViewDataColumn>
        </Columns>
    </dx:ASPxGridView>

    <dx:ASPxPopupControl ID="MyPopup" runat="server">
        <ContentCollection>
            <dx:PopupControlContentControl>
                <dx:ASPxTextBox ID="MyPopupText" runat="server" Width="170px"></dx:ASPxTextBox>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>

Code Side...

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillGrid();
            MyGrid.DataSource = Session["dt"] as DataTable;
            MyGrid.DataBind();
        }
    }

    protected void FillGrid()
    {
        string qwe = "SELECT * FROM xxx";
        DataTable dt = Voldemort1.RC.SQLResults(qwe, Voldemort1.RC.MyConn(), new string[] { }, new object[] { });
        Session["dt"] = dt;
    }

    protected void MyGrid_DataBinding(object sender, EventArgs e)
    {
        if (Session["dt"] == null)
        {
            FillGrid();
        }
        MyGrid.DataSource = Session["dt"] as DataTable;
    }

    protected void ShowMe_Click(object sender, EventArgs e)
    {
        ASPxButton btn = sender as ASPxButton;
        MyPopupText.Text = btn.CommandArgument.ToString();
        MyPopup.ShowOnPageLoad = true;
    }

Reader's Comments

Post Your Comment Posts/Links Rules

Name

Comment

Add a RELEVANT link (not required)

Upload an image (not required)

No uploaded image
Real person number
Please enter the above number below




Home
Admin Ren's Biking Blog