I was searching through the old forums trying to figure out how to bind a value to a Templated Column that is using an Web Image Button. For the most part, I saw unanswered posts from a long time ago. I finally found the answer, so I will post it:
This is what the column code looks like for the grid in the aspx page:
<igtbl:TemplatedColumn Key="RecId" BaseColumnName="RecId" AllowRowFiltering="false" Width="25px">
<CellTemplate>
<igtxt:WebImageButton ID="btnLink" runat="server"
CssClass="pointer"
OnCommand="btnLink_Command" CommandArgument="<%# Container.Value%>" ToolTip="Edit Security">
<Appearance>
<Image Url="~/Image/icon/ico_edit.gif" />
</Appearance>
</igtxt:WebImageButton>
</CellTemplate>
</igtbl:TemplatedColumn>
Here is the code behind button command event:
{
}
I do have one other question though, is it possible to send the data for more than one column or the entire row using the code above?
The answer is, yes it's possible and you're pretty much there. The "Container" in the template is an instance of the "CellItem" class (http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/Infragistics2.WebUI.UltraWebGrid.v7.3~Infragistics.WebUI.UltraWebGrid.CellItem_members.html) which has a "Cell" property that can be used to walk up the chain in the grid. In your case, if you want to get to another cell, use Container.Cell.Row.Cells[index].Value
Hope this helps. I'll be forwarding this post on to our Docs team and pursue getting a topic written up on this as well.
-Tony
Hey Tony, Thanks a lot for the answer. Is it possible for me to access the row info in the code behing in the command method. I would rather not have to pass the whole row in some kind of concatenated list?
What I ended up doing in one case was this:
<igtxt:WebImageButton ID="btnView" runat="server"
CommandArgument="<%# Container.Value%>" CssClass="pointer"
OnCommand="btnView_Command" ToolTip="View this Message">
<Image Url="~/Image/icon/ico_view.gif" />
string Val = e.CommandArgument.ToString();
Session["RefreshNotes"] = "Yes";
This is kind of a backwards way to access the row, as is passing multiplte cell values in the command argument.
I would like to be able to just pass in a pointer to the row, similar to how a row click event works??
Hi,
I was just wondering, I am using an asp.net LinkButton inside Template Column and when I click on this link button it opens up a modal for me which it does but the only thing is that, it does not open up on the first click but only opens up on the second click, it seems like on the first click the link button does not get initialize to the path for the modal but on the second it click it does. If I tried to open the modal again, it only requires one click. Now, if I were to go to the second row, I have to click it twice and the first click would initialize the path to the modal then on the second click, it will open the modal on the first. I tried to initialize it on the Page_Load, InitializeLayout, InitializeRow but it can't find the LinkButton1 control ID that I have named it on the HMTL side. It can find it on the LinkButton1_Click event. I thought I ask my question here because I see above that you use LiteralControl to pass in your javascript functions to open up the pop up. Which I do use and I just need to know how to initialize it for the first time when the page load up so I don't have to click on my link button twice to on each row in order for it to load.
Thanks very much in advance!
HS2
We are having an issue as described in the below KB while using window.open. Microsoft says the issue should be fixed in IE
5.0+. We are using IE6 6.0.2900 SP3 and still having this issue.
http://support.microsoft.com/kb/196383
If we use WebDialogWindow, is there any chance we could get this issue fixed? Any suggestions/experience regaridng this will
be great?
Hello,
window.showModalDialog is IE ony extension not supported in full by most browsers. You can take a look at this forum thread for details:
http://forums.asp.net/p/1088999/1635647.aspx
I personally would recommend using our superb WebDialogWindow component - much prettier and easy to use + works on all browsers. You can find samples for WebDialogWindow in our samples site located here:
http://samples.infragistics.com/2008.2/webfeaturebrowser/default.htm
Protected Sub linkbtn_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
Dim currentRow As UltraGridRow = Nothing
Dim Val As String = e.CommandArgument.ToString()
Dim lbtn As LinkButton = DirectCast(sender, LinkButton)
Dim sPrevCount As String
Dim ci As CellItem = DirectCast(lbtn.Parent, CellItem)
If ci IsNot Nothing Then
Dim r As UltraGridRow = ci.Cell.Row
Dim iRow As Integer = ci.Cell.Row.Index
' this will give you the current row index so if you need the value of the next row or previous row then
Dim iprevrow As Integer = iRow
Dim inextrow As Integer = iRow
sPrevCount = UltraWebGrid.DisplayLayout.Rows(iprevrow).Cells.FromKey("Publication_date").Value.ToString()
sNextCount = UltraWebGrid.DisplayLayout.Rows(inextrow).Cells.FromKey("SampleDataCount").Value.ToString()
Dim sHeight As String = "100"
Dim sWidth As String = "200"
Dim sTitle As String = sPrevCount
sScript = "<script>var rc=new Array(0,0); rc=window.showModalDialog('Report_Search_Detail_Modalpopup.aspx?Title=" + sTitle + "','','height:" + sHeight + " px;width:" + sWidth + " px');" + "" & Chr(10) & ""
'this line of code handle the case where I want to return a value back to parent screen from the modal
'This line of code register the script
Me.ClientScript.RegisterStartupScript(GetType(Page), "showModalDialog", sScript)
Any one have idea for Firefox pop height and width.
Regards
in your event method;
in your link button even
make sure you have the following lines of code:
LinkButton lbtn = (LinkButton)sender;
CellItem ci = (CellItem)lbtn.Parent;
if(ci != null){
UltragridRow r = ci.Cell.Row;
int iRow = ci.Cell.Row.Index; // this will give you the current row index so if you need the value of the next row or previous row then
int iprevrow = irow -1;
int inextrow = irow +1;
then in your code if you want to retreieve values from previous or next cell then use the following line of code:
sPrevCount = webgrid.displayLayout.Rows[iprevrow].Cells.FromKey("Count").Value.ToString();
sNextCount = webgrid.displayLayout.Rows[inextrow].Cells.FromKey("Count").Value.ToString();
Hope that helps.
I have bind two column my Ultragrid. The first column is "DATE" and second one is "Count". The Second Column "Count" I Am bind Linked button. I got current row value(second). I need first row values(Previous) when i check the second row.
Please help to me.
Sudhakar Rao. MCSD.Net,MCTS