Hello all,
I have an ultrawebgrid that has many rows and many columns. On the Task column, I have embedded an asp.net 2.0 LinkButton and in there I have the link to open up a .aspx modal. The modal does opens up on the second click on the Link Button. After the first click it seems to initialize the link opens up the modal and after that when I tried to opens up the modal again on that same row, it will open up on the first click. And if I were to go onto the second row and click the link for the first time, it would not open up the modal, but on the second click, third click , and so on (on that second row), then it will open up the modal.
So my question is, how do I initialize the link to the modal on either Page_Load, InitializeLayout or InitializeRow event methods. I have tried it on all three but none of them work because it cannot find the instance of my asp.net LinkButton.
It seems like, it will only initialize the modal link when it invoke the LinkButton1_Click event.
LinkButton1_Click (object sender, EventArgs e)
{
//Create an instance of the LinkButton
LinkButton lnkButton = (LinkButton) sender;
//some javascript function
script = "javascript code here";
Page.ClientScript.RegisterStartupScript(typeof(Page), "modalDlg", script);
lnkButton.Attributes.Add("onClick", "doIt();"); // doIt(); is the javascript function from the "script" block two lines above
}
I have tried using FindControls ("LinkButton1") but it cannot find it in neither Page_Load, InitializeLayout or InitializeRow.
If someone knows how to solve this, please shred some light on me.
Thanks very much in advance!
Hs2
Thank you for your help,
Regards
Sudhakar Rao – MCSD.Net,MCTS
You can probably have them separated with comma. Say, column[1] is ProductName, and columns[2] is ProductID. Example:
<asp:linkbutton CommandArgument="<%# Eval('ProductID') %>, # Eval('ProductName') %>"
Or you can use CommandName in addition to argument, example
<asp:linkbutton CommandArgument="<%# Eval('ProductID') %>" CommandName="<%# Eval('ProductName') %>"
Thank very much for your help,
I need one more help from you. My Link button number is Columns(2). but i need Columns(1) value when ever i click link button.
please help me.
Sudhakar Rao. MCSD.Net,MCTS
Hello Sudhakar,
You can do it declaratively and use the CommandArgument of the link + databinding expressions to store custom values (0 to 4). They however need to be present in the datasource (each row should have a column with these values - in my case, the column in the datasource is productId
<asp:LinkButton ID="EditSaveButton" Runat="server" OnClick="EditSave_Click" CommandArgument='<%# Eval( "productId" ) %>'>(Edit)</asp:LinkButton>
Thanks, it`s working.
How to bind values in linkbutton cell? Iam bind Ultragrid dynamic. how to move cell link button value 0 to 4?
please help me,
Thanks
Sudhakar