2014年7月13日 星期日

[RESOLVED] asp.net griedview update all row in Update Button Click.


 
                    DataSourceID="Sql_upresult" CssClass="mGrid">

                   

                   

                       

                       

                            SortExpression="stdname" />

                       
                            SortExpression="Course" />

                       

                            SortExpression="ResultType" />

                      



                    

                  

                      

                                       

                   


                   






                       

                       
                            SortExpression="Session" />

                       

                       

                   


               


               
                    ConnectionString="<%$ ConnectionStrings:GreenUniversity %>"

                    SelectCommand="SELECT [stdid], [stdname], [Course], [ResultType], [Result_M], [Class], [Session], [xdate] FROM [Result_std] WHERE (([Class] = @Class) AND ([Course] = @Course) AND ([Session] = @Session) AND ([xdate] = @xdate))">

                   

                       

                            PropertyName="SelectedValue" Type="String" />

                       

                            PropertyName="SelectedValue" Type="String" />

                       

                            PropertyName="SelectedValue" Type="String" />

                       

                            Type="DateTime" />

                   


               


 


i want to update all result from gried view-----------------


i keep text box inside the gried view.



now i want to update all record on button click


how can i update all record in button click.



its quite simple ..


ass a property on row command in your grid view .. 




                    DataSourceID="Sql_upresult" CssClass="mGrid">

                    RowCommand" />


and in your template field 




                  

                      

                                       

                     

                   



in Code Behind 


protected void gridMembersList_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Update")
{

            for (int i = 0;i
               {//Define a DataKey of Student id to get id to update with result in you gridview

                       long SOShipping_ID = Convert.ToInt64(GridView1.DataKeys[i].Value);


            TextBox TbTo Update = (TextBox)GridView1.Rows[i].FindControl("txtResult");

           }//this loop will get access each values of textbox in your grid .. add update query in this loop it will update aal your records .. 
}
}

沒有留言:

張貼留言