DataGrid problem
-
one of the column in my datagrid is binded to some smallint numbers. However, i want every smallint 1 to show as the string "one" and 2 as the string "two" instead of the alpha numerical representation. how do i do that in codebehind programming? thanks very much
-
one of the column in my datagrid is binded to some smallint numbers. However, i want every smallint 1 to show as the string "one" and 2 as the string "two" instead of the alpha numerical representation. how do i do that in codebehind programming? thanks very much
check out this Article Regards R.Arockiapathinathan
-
one of the column in my datagrid is binded to some smallint numbers. However, i want every smallint 1 to show as the string "one" and 2 as the string "two" instead of the alpha numerical representation. how do i do that in codebehind programming? thanks very much
-
one of the column in my datagrid is binded to some smallint numbers. However, i want every smallint 1 to show as the string "one" and 2 as the string "two" instead of the alpha numerical representation. how do i do that in codebehind programming? thanks very much
Create a public function to solve it. maybe just like this: public string ChangeNumber(string strNum) { switch (strNum) { case "1": return "one"; break; case "2": return "two"; break; ... } } maybe this method is so fool but it is a straight .... :( Study...
-
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { switch(@smallint) case 1: e.Item.Cells[0].Text = "One"; case 2: e.Item.Cells[0].Text = "Two"; case 2: . . . } Is that okay
Thanks for the help but that don't work
-
Create a public function to solve it. maybe just like this: public string ChangeNumber(string strNum) { switch (strNum) { case "1": return "one"; break; case "2": return "two"; break; ... } } maybe this method is so fool but it is a straight .... :( Study...
how do i apply that to the datagrid?
-
Create a public function to solve it. maybe just like this: public string ChangeNumber(string strNum) { switch (strNum) { case "1": return "one"; break; case "2": return "two"; break; ... } } maybe this method is so fool but it is a straight .... :( Study...
-
one of the column in my datagrid is binded to some smallint numbers. However, i want every smallint 1 to show as the string "one" and 2 as the string "two" instead of the alpha numerical representation. how do i do that in codebehind programming? thanks very much
If theres a way to avoid it I would You can do an interpretation of the number but that would be difficult or tedious. whichever Define an enumeration
public enum Number zero = 0, one, two, ... etc.. ... }
Now to display the valueConsole.WriteLine("The answer is " + Enum.Parse(typeof(Number), "1", true));
Obviously you would need to define tens, hundreds, and so one.public enum tens { ten = 10, twenty = 20 }
and then concatenate them together. Its very annoying, but if thats what you want it will work. Its ugly but it works. Nick 1 line of code equals many bugs. So don't write any!! -- modified at 9:17 Tuesday 24th January, 2006 -
If theres a way to avoid it I would You can do an interpretation of the number but that would be difficult or tedious. whichever Define an enumeration
public enum Number zero = 0, one, two, ... etc.. ... }
Now to display the valueConsole.WriteLine("The answer is " + Enum.Parse(typeof(Number), "1", true));
Obviously you would need to define tens, hundreds, and so one.public enum tens { ten = 10, twenty = 20 }
and then concatenate them together. Its very annoying, but if thats what you want it will work. Its ugly but it works. Nick 1 line of code equals many bugs. So don't write any!! -- modified at 9:17 Tuesday 24th January, 2006actually, i just want to know how to alter the value of the datagrid cell from a int to a string. Any idea how i am able to do that?
-
actually, i just want to know how to alter the value of the datagrid cell from a int to a string. Any idea how i am able to do that?
Are you using a template column for this in particular? If so, in the ItemDataBound event you can use some of the suggestions that other cpians have offered. daniero
-
actually, i just want to know how to alter the value of the datagrid cell from a int to a string. Any idea how i am able to do that?
You need to change your data source. If this is a table, then change the column data type DataTable.Column["mycolumn"].DataType = typeof(string); Changing the data grid itself will not have a satisfactory desired effect. Change the underlying data source, that way your change maintains consistency. Nick 1 line of code equals many bugs. So don't write any!!
-
Are you using a template column for this in particular? If so, in the ItemDataBound event you can use some of the suggestions that other cpians have offered. daniero
hey, Thanks for the help. That is what i need