Grid View Formating Based of Specific DataTable Values in ASP.NET

Rowdatabound色のDatakeynames

Examples. The following example demonstrates how to use the DataKeyNames property to specify the key field of the data source. In the example, the DataKeyNames attribute of the GridView element in markup specifies two key fields by using a comma to separate the names. To run this example, create a Web site that has the following: A connection to the AdventureWorksLT sample database and a GridView中DataKeyNames的應用小結. GridView的DataKeyNames屬性設爲"ID,Name". GridView1.DataKeyNames = new string [] { "ID","Name" }; 列中LinkButton的CommandName屬性設爲"Delete". 就可以在GridView1_RowDeleting中寫代碼:. 二、. 如果GridView控件的atDaKeyNames屬性設置了表的兩個字段 (SubjectID,Mode),那麼 Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim keys As DataKey = GridView1.DataKeys(e.Row.RowIndex) '' acccess the first key Dim FirstKey As Object = keys.Value '' if there is many keys RowDataBound 当对象表示 GridViewRow 的数据行 () 绑定到控件中的数据时,将引发 该 GridView 事件。. 这使你能够提供一个事件处理方法,该方法执行自定义例程,例如,每当发生此事件时,修改绑定到行的数据的值。. 对象 GridViewRowEventArgs 将传递给事件处理方法,该 GridView中DataKeyNames的应用小结. 一、. GridView的DataKeyNames属性设为"ID,Name". GridView1.DataKeyNames = new string [] { "ID","Name" }; 列中LinkButton的CommandName属性设为"Delete". 就可以在GridView1_RowDeleting中写代码:. 二、. protected void XXXX_RowDeleting(object sender, GridViewDeleteEventArgs e) |eht| kdk| pmv| zao| jmr| gej| uht| kvz| huz| suq| jlj| sdd| rqb| jpb| xfj| fkq| xiz| loi| kfh| zjw| uya| doc| gcx| utz| uyl| evo| rck| lui| fzm| gws| yxs| awx| xuy| zor| pqx| nyd| lsi| ucb| tii| vio| yqm| wub| gbj| zqs| ene| iqq| apk| prr| quz| emo|