62,268
社区成员
发帖
与我相关
我的任务
分享
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" OnDataBound="GridView1_DataBound">
<Columns>
<asp:TemplateField HeaderText="Country Name">
<ItemTemplate>
<%#Eval("CountryName") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//这里的country总为空
Tcountry country = e.Row.DataItem as Tcountry;
e.Row.Attributes.Add("ondblclick", string.Format("alert('{0}')", country.CountryId.ToString()));
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
//这里的country总为空
Tcountry country = e.Row.DataItem as Tcountry;
e.Row.Attributes.Add("ondblclick", string.Format("alert('{0}')", country.CountryId.ToString()));
}