我对网格视图有疑问 [英] I have a problem with grid view

查看:65
本文介绍了我对网格视图有疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我想问你我使用的是字段名ConsultDate是一个Hijri日期,该字段是nvarchar(8)
我在按钮中使用此代码来检索日期

Hi I want to ask you I am using a field name consultDate it''s a Hijri date the field is nvarchar(8)
I use this code in a button to retrieve the date

Dim conn As New SqlConnection(Web.Configuration.WebConfigurationManager.ConnectionStrings("UserManagement").ConnectionString)
      Dim comm As New SqlCommand
      Dim adpt As New SqlDataAdapter
      Dim result As New DataTable

      comm.CommandText = "SELECT SUBSTRING(HIJRI_DATE,7,2) AS DAY,SUBSTRING(HIJRI_DATE,5,2) AS MONTH,SUBSTRING(HIJRI_DATE,1,4) AS YEAR FROM TABLE1 "
      comm.Connection = conn
      adpt.SelectCommand = comm
      Try
          adpt.Fill(result)
          DDL_Day.SelectedValue = result.Rows(0).Item("DAY").ToString
          DDL_Month.SelectedValue = result.Rows(0).Item("MONTH").ToString
          DDL_Year.SelectedValue = result.Rows(0).Item("YEAR").ToString
      Catch ex As Exception
          Throw ex
      Finally
          conn.Close()
      End Try
  End Sub


但是现在我有一个gridview,并且正在使用sqldatasource
日期显示为01021439
如何在它们之间加上/使其成为日期
谢谢


But now I have a gridview and I am using a sqldatasource
the date appears as 01021439
How can I put / between them to make it as a date
Thanks

推荐答案

Dim column1 As New DataGridTextBoxColumn
With column1
    .MappingName = "fieldName"
    .Format = "yyyy/MM/dd"
End With



您可以使用它来格式化数据网格的日期字段.
这应该可以解决您的问题.



You can use this for format the date field of your data grid.
This should solve your problem.


对不起,它不起作用
我正在使用Web应用程序
我应该在其他地方写的代码写在GridView1_SelectedIndexChanged中
????
Sorry it didn''t work
I am using web application
I wrote the code in the GridView1_SelectedIndexChanged should I wrote it in an other place
????


这篇关于我对网格视图有疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆