Story Background: There is a block in the current project, you need to do data updates and delete in DataGrid! There are two TextBoxs above the DataGrid to create new records! And the items in the two TextBox are required, all have two RequiredValidator. Constraint.
Pillage: The function is simple to use ** time to get it, there is no problem with the addition of deletion updates, and you can't help but have a little secret! Later, I want to now the function module is to maintain a simple dictionary table two TextBox The project should be a required project. Although the customer has not filed this problem (the customer is generally a mentally ministry ^ _ ^), in order to showcase a selfValidator verification, the delete button is in order to use the so-called XP So put it in the template column, I set up causevalidation for false, I still think of the revised re-test after I want to be a habit, add, delete operation no problem! When I edited, I thought about it. 90% of the problem! But when I update the button, I must admit that I am a very unfortunate person, why is it so small that I will always meet! One percent of the possibility If you touch I will expand and then expand and then to 100%. Of course I said the top ten bad things! The good thing is the opposite, this is the reason I never buy a lottery, I have never participated in the cause of the award! ^ _ ^, Long.
The plot: I am very skilled, I'm trying to open the ASPX page, trying to find Causevalidation in the attribute of the column, but I haven't found it carefully! Wrap will press F7, think about doing some articles in codebehind, but the results are obvious ,well known by all people!
I am A Failure! No way I can only rely on search engines, I am very habitually I prefer to directly get 9CBS! Keyword causevalidation, search ...! Fortunately, find two! There is a boss Answer, the general idea is to convert the cell [n] .control [n] to Button!
Dim t as datagriditem = dgdscoreshow.items (E.Item.itemindex) Dim k as linkbutton = ctype (t.cells (0) .controls (0), linkbutton) K.causesvalidation = false Of course, his code is C #, I I moved the code of the Site but I can't use it! Mushi's code has a mistake, although I am not superstitious, but his code is always coming! I suddenly thought that I printed the Control. It is clear that the type is not clear, so I added the following code response.write ("editcommandcolumn" t.cells (0) .controls (0) .gettype.tostring "
"), run! Printing is System.Web.ui.WebControls.DataGridLinkButton!
I am stealing!, This is not!
Dim Button As DataGridLinkButton said that DataGridLinkButton is "private", which is not accessible in the context.
I fell!
That is converted to the base class. What is the base class? Maybe it is linkbutton! I think so.
I will try it out. So I wrote the following code. Dim bt as linkbutton = ctype (dgdscoreshow.Items (E.Item.itemindex) .Cells (0) .controls (0), linkbutton Bt.causeesValidation = false
Ctrl F5, really good me!
So I thought, why do you write button instead of linkbutton! Could he make a mistake! Suddenly I think there is a commandType property, inspiration, must be a problem.
I have modified the attribute of the editor to commandType = pushbutton, then use the way to the way, the results prove that my IQ is still very good D!
I tried to print the current Cells (0) .controls (0) .gettype! The result is system.web.ui.webcontrols.button! I am very emotion, MS is very great, but what makes it feel a bit BT, setting up CommandType, different things that seem to have no big relationship, a system.web.ui.webcontrols.dataGridLinkButton is Private, and the other is system.web.ui.webcontrols.button, naturally you can access !
So I tried to print different columns in DataGrid.
EditCommandColumn System.Web.UI.WebControls.ButtonBoundColumn System.Web.UI.WebControls.TextBoxButtonColumn System.Web.UI.WebControls.DataGridLinkButtonHyperLinkColumn System.Web.UI.WebControls.HyperLinkTemplateColumn System.Web.UI.WebControls.HyperLink
This is the true side of the road!
Of course, the last template column can print out what is decided to put things yourself!
When I now understand why the ** inside the inside of DataGrid will appear like this to make me the code that I can't model my mind: TextBox txtitem; textbox txtitemkind;
INTITEMID = (int) DGDSCoreTemplate.DataKeys [E.Item.itemindex]; txtitem = (textbox) E.Item.cells [3] .controls [0]; txtitemkind = (TextBox) E.Item.cells [2] .controls [0]
It turns out that there are some Button, Hyperlink, Textbox!
Really suddenly!
Code segment:
aspx =================================================== ======================