protected void ASPxGridView1_CustomColumnDisplayText(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDisplayTextEventArgs e)
{
if (e.Column.VisibleIndex == 8)
{
string users= e.GetFieldValue ("account").ToString();
string str_right = "select product_right from tbl_admin where account='"+users +"'";
SqlDataReader dr = co.storereadershop(str_right );
if (dr.Read())
{
e.DisplayText = dr[0].ToString();
}
}
}
AspxGridView中根据判断隐藏某个值的事件
OnCustomColumnDisplayText="Grid_CustomColumnDisplayText"
中放一列普通列
<dxgw:GridViewDataTextColumn Caption="操作" VisibleIndex="7" Width="28px" HeaderStyle-HorizontalAlign="Center">
</dxgw:GridViewDataTextColumn>
-----------------------------------------
方法
protected void Grid_CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e)
{
if (e.Column.VisibleIndex == 7)
{
//如果ItemType等于1显示超链接,不等于1不显示
if (e.GetFieldValue("ItemType").ToString().Equals("1"))
{
e.DisplayText = "<a href=\"javascript:void(0);\" onclick=\"OnSetRuleClick(this,'" + e.GetFieldValue("ItemID") + "')\">设置规则</a>";
}
else
{
e.DisplayText = "";
}
}
}
--------------------------
超链列
<dxwgv:GridViewDataColumn Caption="标题" VisibleIndex="1" HeaderStyle-HorizontalAlign="Center"
Width="50%">
<Settings AllowSort="False" />
<EditFormSettings Visible="False" />
<DataItemTemplate>
<a href="javascript:void(0);" onclick="OnMoreInfoClick(this,'<%# Container.KeyValue %>')">
<%#Eval("Title")%></a>
</DataItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
</dxwgv:GridViewDataColumn>