开发者

LinkButton - bind field to ToolTip or CSSClass

I have a legacy asp.net 3.5 application. I need to bind a filed to CssClass so that i can utilize it via jquery.

Basically, in the datagrid, there are 2 buttons. Button one is visible and button two is not visible. On click of button one, i want to perform action and then make button two visible and hide button one. How can i do this? I just need a kick in the right direction...

<asp:LinkButton ID="lnkDelete" runat="server" 
    ToolTip="Delete Order <%# DataBinder.Eval(Container.DataItem, "TransID")%>" 
    OnClientClick="return DeleteOrder();"                                                
    OnClick="OrderDelete" CommandArgument='<%# Eval("Tra开发者_如何学CnsID")' 
    CssClass=""> 
    <asp:Image ID="Image1" runat="server" ImageUrl="~/images/icons/delete.gif"
        BorderStyle="None" />
</asp:LinkButton>

My current binding inside the tooltip results in an error, "the server tag is not well formed".

On the code behind OrderDelete, i can disable the delete link, but how can i make the other button visible?

//delete indivisual order
protected void OrderDelete(object sender, EventArgs e)
{
    string transactionID = String.Empty;
    LinkButton lnkDelete = (LinkButton)sender;
    if (lnkDelete != null)
        transactionID = lnkDelete.CommandArgument;

    if (!String.IsNullOrEmpty(transactionID))
    {
        //do delete
    }
    //refresh results

}


For the server tag not well-formed error, try something like this:

ToolTip='<%# String.Format("Delete Order {0}",  DataBinder.Eval(Container.DataItem, "TransID")%>'

For the second part of your question, a little more of your code might help to give you a more specific answer, but in lieu of that, if you know which row of the DataGrid you're in, you should be able to do a FindControl in that row for the second button and make it visible.

Update

You might try setting the tooltip in the codebehind, using the RowDataBound event. Something like this:

protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{

    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        LinkButton btn = e.Row.FindContorl("lnkDelete") as LinkButton;

        // You'll need to retrieve the values you want to dynamically populate 
        // the ToolTip with from other controls in the row;
        // I don't know if you'd be able to use the DataSource or not, but you might.
        btn.ToolTip = "Delete Order "; 
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜