c# - How edit dataset column value in asp.net -


Hello, I have a database where 5 columns in a table fills out data from the database.

When there are more than 50 rows in the data I run the application, I would like to update the value of the data after receiving the data from the database. I have needs

  1. In this table are some cells with tap values, I would like to replace the blank with "-"?
  2. A column is the System.datetime datatype, where I want to take the time, just want to date?

I am using the push approach in this dataset in the crystal report of asp.net.

Here I am thinking that I apply a loop of rows in the data and update the cells accordingly. But am I searching for any direct update method?

Please help me how can I solve 2 issues?

alternative form From, to automatically generate content, create new columns in the table. ("Foo_dash", typeof string), "isool (afu, '-')"); Add column ("bar_assash", "bar"). Typef (string), "isal (bar, '-')");

(I do not know date function in ado.net, so you have to find yourself last time .)

You have your ASP.NET post, so I think it is fair to believe that you have given some multi-record data control ( GridView to your DataTable , repeater ) Binds>, ​​etc.). If this is the case, then it may be better to make changes during databases instead:

  Secure grid theGrid_OnRowDataBound (Object Sender, GridViewRowEventArgs e) {var data = eDataItem DataRowView; If (data! = Null) {if (data.Row.IsNull ("foo")) e.ro.Cells [0] = "-"; If (Data.r.Isnale ("bar") e.ro.Cells [0] = "-"; }}  

Although this requires a bit more code, it also gives you more flexibility. Example:

  if (data.rose.isnal ("important field") e.row.CssClass = "error";  

In a GridView , the column can be formatted using a date in the declaration:

  & lt; Asp: BoundField DataField = "Data" Dataformat String = "{0: d}" />  

Similarly a repeater :

  & lt;% # Eval ("Date", "{0: d}")% ​​& Gt;  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -