This is a migrated thread and some comments may be shown as answers.
Need help withItem Template setting a label and link parmarmeters
2 Answers 26 Views
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 24 Jun 2010, 03:41 PM
I'm using an Item template to display my grid.  I've used the Cardview example as my starting point and went from there.  I've got everything working well except for two issues.  I need to be able to set a label for each row.

First, I need to set the value of a lablel. The label would actually be the same value for every row but it's not held within the database. It's calculated in the code behind.  I'm assuming I'd use the itemcreated event to set the value but I'm not sure how to access it.  Can some one help me out with that or point me to a clear example?

The second, I have an anchor tag that would allow the user to open up a new window to view Details of the selected row.  I need to be able to set paramaters in the link that I'll be retrieving from the database to pass to the new page to be picked up by th querystring.  I
tried <href="UrlBlockedError.aspx?syscode=" + <%# Eval("Syscode") %> target="_blank">Details</a>    but it didn't get picked up and it messed up the display.  How can I set the parms for the URL?

Here's my template:
You'll notice next to lblDateRange1 a hard coded date range. That's what I need to set the label to.
                                <ItemTemplate> 
                                <div style="width:900px">  
                                    <div style="float:left"><asp:Label ID="lblDateRange1" runat="server" Text="Label"></asp:Label>5/15/2010-5/20/2010 to 5/21/2010-5/26/2010 </div> 
                                    <div style="float:right"><href="UrlBlockedError.aspx" target="_blank">Details</a> 
                                    </div> 
                                    <div style="float:left; clear:both; width:10%"><%# "System: " +Eval("Syscode") %></div>                                      
                                    <div style="float:left; width:30%"><%# "Line of Business: " + Eval("LineofBusiness")%></div>  
                                    <div style="float:left; width:20%"><%# Eval("CodeType") + ": " %> <%# Eval("Code")%> </div> 
                                    <div style="float:left; width:20%"><%# "AA Rate Drop: " + Eval("System_Adj_Rate_Drop")%></div>  
                                    <div style="float:left; width:20%"><%# "ADJ Claims Chang: " + Eval("Claims_Manually_Adj_Drop") %></div>  
                                     
                                    <div class="tablediv">  
                                        <div class="rowdiv">  
                                            <div class="celldiv">&nbsp;</div> 
                                            <div class="celldiv">Received Claims</div> 
                                            <div class="celldiv">Completed Claims</div> 
                                            <div class="celldiv">Auto Adjucicated Claims</div> 
                                            <div class="celldiv">AARate</div> 
                                        </div> 
                                        
                                        <div class="rowdiv">  
                                            <div class="celldiv">Previous:</div> 
                                            <div class="celldiv"><%# Eval("Prev_Claims_Received")%></div>  
                                            <div class="celldiv"><%# Eval("Prev_Claims_Completed") %></div>  
                                            <div class="celldiv"><%# Eval("Prev_Total_Auto_Adj_Claims")%></div>  
                                            <div class="celldiv"><%# Eval("Previous_Auto_Adj_Rate") %></div>  
                                        </div> 
                                          
                                        <div class="rowdiv">  
                                            <div class="celldiv">Current:</div> 
                                            <div class="celldiv"><%# Eval("Claims_Received") %></div>  
                                            <div class="celldiv"><%# Eval("Claims_Completed") %></div>  
                                            <div class="celldiv"><%# Eval("Total_Auto_Adj_Claims") %></div>  
                                            <div class="celldiv"><%# Eval("Current_Auto_Adj_Rate") %></div>  
                                        </div> 
                                      
                                    </div> 
                                 </div> 
                                </ItemTemplate> 

2 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 24 Jun 2010, 04:16 PM
I figured out how to set the link with the parms I needed.  If anyone is interested here's how it is done.

<

 

asp:HyperLink ID="HyperLink1" runat="server" Target="_blank" NavigateUrl='<%# "BlockedError.aspx?syscode=" + Eval("Syscode") + "&lob=" + Eval("LineofBusiness") %>'>Details</asp:HyperLink>

I still need help figuring out how to set the label.

0
Michael
Top achievements
Rank 1
answered on 24 Jun 2010, 04:46 PM
Well it looks like I've answered my own questions.  After some more digging I  tried something similar to what I was trying before in the item created event and it worked.
For those interested:

 

protected void WDRGrid_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)

 

{

 

if ((e.Item is GridDataItem))

 

{

 

GridDataItem dataItem = (GridDataItem)e.Item;

 

 

Label lblRange = (Label)dataItem.FindControl("lblDateRange1");

 

lblRange.Text = strDateRange;

}

}

Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Share this question
or