Add an onclick event in the DataGrid for any Column
2006-11-01 16:45
288 查看
protected void ItemDB(object sender , System.Web.UI.WebControls.DataGridItemEventArgs e )
{
DataView dv = (DataView)DataGrid1.DataSource;
DataColumnCollection dc = dv.Table.Columns ;
string strID;
foreach (DataColumn dcCol in dv.Table.Columns)
{
if ((e.Item.ItemType == ListItemType.AlternatingItem )||(e.Item.ItemType == ListItemType.Item ))
{
strID = DataGrid1.DataKeys[e.Item.ItemIndex].ToString ();
e.Item.Cells[dc.IndexOf(dc[dcCol.ColumnName])].Attributes.Add("style", "cursor:hand");
e.Item.Cells[dc.IndexOf(dc[dcCol.ColumnName])].Attributes.Add("onclick", "javascript:window.open('details.aspx?id=" + strID + "'," + "'MyPage','height=300,width=300')");
}
}
}
{
DataView dv = (DataView)DataGrid1.DataSource;
DataColumnCollection dc = dv.Table.Columns ;
string strID;
foreach (DataColumn dcCol in dv.Table.Columns)
{
if ((e.Item.ItemType == ListItemType.AlternatingItem )||(e.Item.ItemType == ListItemType.Item ))
{
strID = DataGrid1.DataKeys[e.Item.ItemIndex].ToString ();
e.Item.Cells[dc.IndexOf(dc[dcCol.ColumnName])].Attributes.Add("style", "cursor:hand");
e.Item.Cells[dc.IndexOf(dc[dcCol.ColumnName])].Attributes.Add("onclick", "javascript:window.open('details.aspx?id=" + strID + "'," + "'MyPage','height=300,width=300')");
}
}
}
相关文章推荐
- An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON
- An explicit value for the identity column in table 'users' can only be specified when a column list
- [Android 問題] How to Add a Button in ListView, and Make the Event of onClick and onItemClick Coexist?
- OSCache的源码编译Cache.java 文件报add(Class, T) in the type EventListenerList is not applicable for the arguments 错误的解决
- 191 You observed the following output for a user session: SQL > SELECT sid, event, seconds _in _wait
- Typically this problem occurs when you are putting in a data that is too long for the column. In t
- Listening for the link event in a Flex Label control
- java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for
- WebKit discarded an uncaught exception in the webView: <NSUnknownKeyException> valueForUndefinedKey:
- '4.294967295E9' in column '7' is outside valid range for the datatype INTEGER.
- FAT file system-Given any valid cluster number N, where in the FAT(s) is the entry for that cluster number?
- 92.You executed the following commands in an RMAN session for your database instance that has failur
- [转] When exactly does the virtual table pointer (in C++) gets set for an object?
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- Here's an example that shows how to enumerate through the features of a selection set, returning the value of each field in the attribute table except for the geometry colum.
- MySQL - EF : The value for column 'IsPrimaryKey' in table 'TableDetails' is DBNull
- 报错:The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the ar
- To set the div position(used for DataGrid Imeplate Column with DropDownList item)
- Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server.
- How to get the MouseEvent coordinates for an element that has CSS3 Transform?