c# - GridView row editing -


I have a gridview with five bound fields. When inserting values ​​into the grid, I get the textbox field in the cells and it is working fine.

An issue when I need to edit my line, I just need to make 3 cells editable and the other two The cells should only be left to read. How can I get this? Gridview = "none" backender = "Whaitsmok" CssClass = "grid View" AlternatingRowStyle-CssClass = "alt" PageSize = "8" onrowcancelingedit = "GridView1_RowCancelingEdit" onrowdeleting = "GridView1_RowDeleting" onrowediting = "GridView1_RowEditing" onrowupdating = "GridView1_RowUpdating" onrowdatabound = "GridView1_RowDataBound" onrowcommand = "GridView1_RowCommand "Onrowcreated =" GridView1_RowCreated "& gt; & Lt; RowStyle BackColor = "#EFF3FB" /> & Lt; PageSets pageBitton = "5" /> & Lt; Columns & gt; & Lt; ASP: TemplateField & gt; & Lt; HeaderTemplate & gt; & Lt; Asp: LinkButton id = "btnInsert" runat = "server" text = "Command" CommandName = "Insert" ForeColor = "White" /> & Lt; / HeaderTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; Asp: CommandField HeaderText = "Edit-Update" ShowEditButton = "True" /> & Lt; ASP: Boundfield datedfield = "department" header tag = "section id" read only = "true" /> & Lt; ASP: BoundfieldDefined = "Department code" header text = "section code" /> & Lt; ASP: Boundfield Dated Field = "Deputy Descript" Header Text = "Details" /> & Lt; Asp: CommandField HeaderText = "Delete" ShowDeleteButton = "True" /> & Lt; / Column & gt; & Lt; PagerStyle CssClass = "pgr" & gt; & Lt; / PagerStyle & gt; & Lt; FooterStyle BackColor = "# 507CD1" font-bold = "true" ForeColor = "white" /> & Lt; PagerStyle BackColor = "# 2461BF" ForeColor = "White" Horizontal Alliance = "Center" /> & Lt; Selected light BackAcllor = "# D1 ddf1" font-bold = "true" foreclosure = "# 333333" /> & Lt; Header Style BackAcllor = "# 507CD1" font-bold = "true" ForeColor = "white" /> & Lt; EditRowStyle BackColor = "# 2461BF" /> & Lt; AlternatingRowStyle BackColor = "White" /> & Lt; / ASP: GridView & gt;

The code to enter the value for the grid:

  protected zero gridwave 1_RO COMAND (object sender, gridwave command and brick AD E) {if (e. CommandName == "Insert") {DataTable DT = New DataTable (); DT = Pancidio Gate departments (); Datarao Dr. DT. NRO (); D.T.RoInstate (DR, 0); GridView1.EditIndex = 0; GridView1.DataSource = DT; GridView1.DataBind (); (LinkButton) GridView1.Rows [0] .cel [1] .control [0]). Text = "insert"; }}   

line â ?? DUTTING CODE:

  GridView1.EditIndex = e.NewEditIndex;   

Insert and update:

  Protected Zero GridView 1_routing (Object Sender, GridViewUpdate Eventor E) {If (GetDeptCode ()) {lblMessage.Text = " Already includes a single code with the same name code "; } And if (checkcode length ()) {lblMessage.Text = "the length of the department code letter is 3"; } Else {if (LinkButton) GridView1.Rows [0] .cell [1] .control [0]. Text == "insert") {DepertmentProperties DP = New DepertmentProperties (); DP.DeptCode = ((Textbox) GridView1.Rows [0] .cel [3] .control [0]). Text.ToString (); DP.DeptDescription = ((Textbox) GridView1.Rows [0] .Sell [4]. Control [0]). Text.ToString (); PinCDAO.InsertDepartment (DP); } Other {DepertmentProperties DP = New DepertmentProperties (); DP.DidID ​​= Convert.OINIT32 (Gridview 1.RO [E.R.Ondx]. Cell [2] .txt.Tostring ()); DP.Dietcode = ((Textbox) Gridview 1. ROS [E. Randex]. Sel [3]. Control [0]). Text. Toasting (); DP.Descriptation = ((Textbox) Gridview 1. ROS [E.ROIndex]. Seals [4]. Control [0]). Text. Toasting (); PinCDAO.UpdateDepartment (DP); } GridView1.EditIndex = -1; BindData (); LblMessage.Text = ""; }}    

set to "right" < / Html>

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -