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 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.
Regards
Sudhakar Rao. MCSD.Net,MCTS
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.
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.
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
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?