TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vignesh t
NA
63
20.4k
Disable hyperlink if cell value null in gridview
Jan 16 2018 3:14 AM
I have a grid where columns are populated dynamically. I have a column called ID which will have hyperlink enabled and hyperlinks needs to be disabled if cells value is null or empty.
Code:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < GridView1.HeaderRow.Cells.Count; i++)
{
string strHeaderRow = GridView1.HeaderRow.Cells[i].Text;
if (strHeaderRow == "ID")
{
string strMktURL = "http://www.address.com";
HyperLink hlColumns = AddHyperLink(e.Row.Cells[i], strMktURL);
}
}
}
}
protected HyperLink AddHyperLink(TableCell cell, string strURL)
{
HyperLink hl = new HyperLink();
hl.Text = cell.Text;
hl.Font.Underline = true;
hl.Target = "_blank";
hl.NavigateUrl = strURL;
hl.Attributes.Add("style", "color:Black;");
cell.Controls.Add(hl);
return hl;
}
Please suggest how this can be achieved.
Reply
Answers (
5
)
how to send bulk sms in batches of 100 sms using loop
regarding Checkbox in mvc