在RowDataBound事件中..if (e.Row.RowType == DataControlRowType.DataRow) //判断是否数据行;{ DataRowView drv = (DataRowView)e.Row.DataItem; string haveimg = drv["Hd_HaveImage"].ToString(); string uid = drv["Hd_Id"].ToString();} 可以直接读取数据库中未绑定到列的字段. 或者可以用if (e.Row.RowType == DataControlRowType.DataRow) //判断是否数据行;{ string haveimg = DataBinder.Eval(e.Row.DataItem , "Hd_HaveImage").ToString();}
解决方案 »
- FCKeditor控件怎么用的???急!!请大家帮我解决!!!
- 如何用ASP.NET局部刷新两个DIV
- <div>和<form>之间出现异常空隙
- 如何将输入文本框的邮箱地址转变成图片?
- 我有个asp.net的项目。怎么部署?
- [加急兼职,版主高抬贵手匆删]河南搞WAP的朋友和我联系!
- Response.Write("<script>window.showModalDialog ....的问题
- 如何在DropDwonList中动态绑定数据库中指定表的列名
- 取出photoshop图片里的文字 把格式和效果都粘贴到asp页面上
- 导航的关闭和打开
- c# windows form 的combobox为什么不显示数据呢
- 想在腾讯开放平台上开发自己的应用
//GridView设置显示数据功能
<asp:GridView ID="gvGoodsInfo" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" Font-Size="9pt"
AutoGenerateColumns="False" AllowPaging="True" PageSize="8"
OnPageIndexChanging="gvGoodsInfo_PageIndexChanging" Width="450px">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#CBCF7A" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#CBCF7A" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="PicId" HeaderText="商品ID" />
<asp:BoundField DataField="PicType" HeaderText="所属类别" />
<asp:BoundField DataField="GoodsStock" HeaderText="库存量" />
<asp:BoundField DataField="PicName" HeaderText="商品名称" />
<asp:HyperLinkField HeaderText="详细信息" Text="详细信息" DataNavigateUrlFields="PicId"
DataNavigateUrlFormatString="EditGInfo.aspx?GoodsID={0}" Target="mainframe"
NavigateUrl="~/MemberManage/EditGInfo.aspx" >
<ControlStyle Font-Underline="False" ForeColor="Black" />
<ItemStyle Font-Underline="False" ForeColor="Black" />
<HeaderStyle Font-Underline="False" ForeColor="Black" />
</asp:HyperLinkField>
</Columns>
</asp:GridView>//codego.net/tags/11/1/
//cs页面绑定GridView控件加载数据
SqlConnection sqlcon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
protected void Page_Load(object sender, EventArgs e)
{
string sqlstr = "select * from tbPicture"; //创建执行查询操作的SQL语句
sqlcon.Open();//打开数据库连接
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);//创建数据阅读器
DataSet myds = new DataSet(); //创建数据集
myda.Fill(myds); //填充数据集
gvGoodsInfo.DataSource = myds; //设定数据源
gvGoodsInfo.DataBind(); //绑定数据
sqlcon.Close(); //关闭数据库连接
}
如果DataRowView不是DataItem 的子类 是不可以转的我现在很少用控件了,都mvc了
你可以搜索一下GridView 72般绝技