下面的代码工作正常,并将datatable绑定到asp.net网格
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
Grid1.DataSource = ds;
Grid1.DataBind();
<asp:GridView ID="Grid1" runat="server" GridLines="Both" CellPadding="4" OnRowDataBound="Grid1_OnRowDataBound">
</asp:GridView>网格中的第一行,显示这样的文本--“快速褐狐跳跃”
如何在网格中显示这一点--“快速褐狐跳跃”
第一个字符需要大写。
发布于 2018-12-07 12:14:43
您可以处理RowDataBound事件。
假设您使用的是BoundFields,并且文本位于第一栏中:
void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
string oldText = e.Row.Cells[0].Text;
if(!string.IsNullOrWhiteSpace(oldText))
e.Row.Cells[0].Text = char.ToUpper(oldText[0]) + (oldText.Length > 1 ? oldText.Substring(1) : "");
}
}https://stackoverflow.com/questions/53669265
复制相似问题