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
Hi,
If you don`t mind can you send code for me. last two weeks iam tring to implemented same functionlities. but i can`t please help me.
Hello,
Sorry for replying so late b/c i wasn't able to check email.
Design:
What you need to do is actually really simple: In your webgrid, create a templatedcolumn and use an asp:LinkButton
<igtbl:TemplatedColumn AllowUpdate="No" Key="TestColumn"> <CellTemplate> <asp:LinkButton ID="lBtnTest" runat="server" Text="Test" OnClick="lBtnTest_Click" /> </CellTemplate> <Header Caption="Test Column"> <RowLayoutColumnInfo OriginX="9" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="9" /> </Footer> </igtbl:TemplatedColumn>
C# Code in behind:
In your C# code, you inside the linkbutton event,
protected void lBtnTest_Click(object sender, EventArgs e){
string sScript = null;
string sHeight = 400px; // or whatever size you want your modal to be
string sWidth = 400px; // or whatever size you want your modal to be
//If you need to pass any data to the modal then do it in the line below after the sTitle variable
sScript = "<script>var rc=new Array(0,0); rc=window.showModalDialog('Test.aspx?Title=" + sTitle + "','','dlgHeight:" + sHeight + " px;dlgWdith:" + sWidth + " px');" + "\n";
//this line of code handle the case where I want to return a value back to parent screen from the modal sScript += "if(rc!=null){document.getElementById('returnvaluetoparentscreen').innerText=rc[0]; __doPostBack('','');}</script>";
//This line of code register the script
this.ClientScript.RegisterStartupScript(typeof(Page), "showModalDialog", sScript);
If you just take this code and follow my example, it should give / invoke the modal and whatever you need to pass to the modal, you can do it after you can get it to invoke.
Let me know if you need futher help.
HS2
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
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>
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.
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') %>"
Sofia,
Thanks for your help.
InitializeDataSource Event not match for my requirement. any other aways possible to implement?
I am also trying to pick up the pieces and get the whole picture right, but it is a bit difficult for me to get everything right away. For DataBinding, I would suggest a couple of things
1) If possible, always use the InitializeDataSource event of the grid to bind the grid with data - this event is automatically called when the grid needs data
2) Take a look at the following blog post - it provides internal insights how data is bound to the grid and how to use it
http://blogs.infragistics.com/blogs/tony_lombardo/archive/2008/01/29/demystifying-infragistics-webgrid-databinding.aspx
Helloo,
Please help me below issues
This is the first time I am using Infragistics controls, I have searched this forum and the net but have not found a solution to my problem.
I have a search form on my .Net page, on pressing a submit I bind the UltraWebGrid(from code behind) and make the asp Panel contianing the UWG visible. One of the Columns of the UWG is a templated column containing an ASP linkbutton. OnClick of the link button is wired on the page. There is no paging on the grid.
So far so good. I get an error when I press the Link button; object reference not set...... The error points to one of the controls on the templated columns. It seems some sort of rebinding is required...something to do with viewstate.
Can some help me in figuring out what could be wrong, perhaps pointing to some code sample that does what I have described above.
Thanks for help. I have found the solution and resolved the issues.
Code:
<igtbl:TemplatedColumn>
<CellTemplate>
<asp:LinkButton ID="linkBtn" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"SampleDataCount")%>' CommandName="SampleDataCount" ForeColor="#3F0400" ><%#DataBinder.Eval(Container.DataItem,"SampleDataCount")%></asp:LinkButton>
</CellTemplate>
</igtbl:TemplatedColumn>
</Columns>
Sudhakar Rao - MCSD.Net,MCTS
Please help me this question also:
How to bind Link button dynamic? using the UltraWebGrid_InitializeLayout.