Hi
I have below gridview in which there is one column Amazon Link. I want to be displayed as Amazon Link & when clicked it should open in another window
SQLUtility sQLUtility = new SQLUtility();
DataTable dt = sQLUtility.GeBookPlanningRecommendation(HRpl, BookCollection, StudentCollection).Tables[0];
if (dt != null)
{
DataColumn Remarks = new DataColumn("Remarks", typeof(string));
dt.Columns.Add(Remarks);
grdPlanning.DataSource = dt;
grdPlanning.DataBind();
}
Thanks
Mohamed Azarudeen ZPosted May 21, 2023, 6:41 AM
To display short description alone kindly check this code
In this updated code, yOu cann use a BoundField to display the "AmazonLink" column directly.
Tuhin PaulPosted May 21, 2023, 4:43 PM
To optimize the code, you can use a TemplateField instead of a BoundField to have more control over the display of the "AmazonLink" column. Here's an optimized version of the code:
CSS:
C#:
In this optimized version, we replaced the BoundField with a TemplateField and directly added an anchor tag (``) within the ItemTemplate. This allows you to customize the link text and navigate URL directly in the markup. The C# code remains the same, but I changed the event handler name to match the event name in the markup (`grdPlanning_RowDataBound`). Additionally, we only need to set the CSS class for the link in the RowDataBound event handler.
Mohamed Azarudeen ZPosted May 21, 2023, 7:25 AM
Great
Ramco RamcoPosted May 21, 2023, 7:05 AM
Hi Mohamed
I have autogeneratecolumns = true
Thanks
Ramco RamcoPosted May 21, 2023, 6:23 AM
Hi Mohammed
If i just want to display short description then what should be done.
Thank
Mohamed Azarudeen ZPosted May 21, 2023, 6:15 AM
Hi Ramco to open amazon tan in another window in gridview try this code
Hope this helps