Convert integer to String in Gridview

  • Thread starter Thread starter wgraulich
  • Start date Start date
W

wgraulich

Guest
I have a gridview on webpage that is linked to a sql database. one of the columns in the database is JurisdictionID and the label for the column for this data is labeled as Jurisdiction. I want to convert the numbers in this column to text. Example: JuridictionID 99 should display as "Dispatch in the gridview, JurisdicitionID 48 should display at "Test2" and JurisdictionID 65 should display as "Test3". The script I wrote will not work. What am I doing wrong?
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{

Label type = (Label)e.Row.FindControl("Jurisdiction"); if (type.Text == "99")
{

type.Text = "Dispatch";
}

else if (type.Text == "48")
{

type.Text = "Test2";
}

else if (type.Text == "65")
{

type.Text = "Test3";
}
}
}
}
}

Continue reading...
 
Back
Top