Hello,
In MySQL table I have two columns Data1 and Data2.
The column Data1 is always full, while the Data2 can be empty or null.
I need to display the Date1 value in the gridview when the Date2 is null or empty.
I tried this code, but when the Date2 is empty or null the Date1 value is not displayed.
protected void g_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string tData2 = DataBinder.Eval(e.Row.DataItem, "Data2").ToString();
string tData1 = DataBinder.Eval(e.Row.DataItem, "Data1").ToString();
Label tlb_Data = (Label)(e.Row.FindControl("lb_Data"));
if (String.IsNullOrEmpty(tData2))
{
tlb_Data.Text = tData1.ToString();
}
else
{
tlb_Data.Text = tData2.ToString();
}
}
}