Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi progs,

i have a gridview that when i edit records it takes me to another view(labels and textboxes) the thing i want is i have a Status column and it takes values "0" for Active and "1" for InAvtive and i need it that when i choose one of these values display on the grid (Active , InAvtive) knowing that the coulmn type is int and am trying to do that throw rowdatabound but no luck....!!??
Posted

Could you put the code you used in the rowdatabound cause this best getway to do what ever you want , here an Ex:
protected void OnRowDataBound(object sender, EventArgs e)
 {
   GridViewRowEventArgs ea = e as GridViewRowEventArgs;
     if (ea.Row.RowType == DataControlRowType.DataRow)
     {
         DataRowView drv = ea.Row.DataItem as DataRowView;
         Object ob = drv["Phone"];
         if (!Convert.IsDBNull(ob))
         {
             Int64 iParsedValue = 0;
             if (Int64.TryParse(ob.ToString(), out iParsedValue))
             {

                 TableCell cell = ea.Row.Cells[4];
                 cell.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, 
                    "{0:(###) ###-####}", new object[] { iParsedValue });
             }
         }
     }
 }
 
Share this answer
 
v2
You should see MSDN's page on customizing the grid view[^]

That said you could simply do (within the templatefield -> ItemTemplate)
<%# Eval("ColumnContainingInt").ToString() %>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900