Add the layer to the GridView, click Open, expand this layer, and vice versa

Source: Internet
Author: User
In the GridView to cover a layer, click ' Open ' to expand this layer, whereas
The JavaScript used is as follows:
< script type = "Text/javascript" >
<! [cdata[
function ShowHidden (Sid,ev)
{
EV = EV | | Window. event;
var target = Ev.target | | Ev.srcelement;
var odiv = document.getElementById ("div" + sid);
ODiv.style.display = ODiv.style.display = = "None"? "Block": "None";
target.innerhtml = ODiv.style.display = = "None"? "Show": "Hidden";
}
]]>
</script >

The code invoked in the GridView is as follows:
< ItemTemplate >
< div style = "font-weight:bold; Background-color: #DEDEDE; ">
< SPAN style = "float:right;
color:red; Cursor:pointer "onclick=" ShowHidden (' <% #Eval ("order_id")%> ', event) ' > Show </span></div>

< div style = "display:none; "id =" div<% #Eval ("order_id")%> ">
< table >
< tr >
< td >
Remark: </td >
< td colspan = "2" >
< Asp:textbox ID = "Txtordertext" runat = "server" Height = "47px" TextMode = "MultiLine" Text = ' <% #Ev Al ("Order_text")%> ' Width = "122px" ></asp:textbox ></td >
</TR >
< tr >
< td >
</td >
< td colspan = "2" >
< Asp:button ID = "btsend" runat = "server" Text = "issue" OnClick = "Button1_Click"/></td >
</TR >
</table >
</div >
</ItemTemplate >
Some people may be a bit confused, I add a button in the GridView, but I double-click the button into the button's onclick event, how do we get the line we clicked the ID (that is, the main building of our database) value.
We often take gridview1.cell[0 in the bound event of Girdview. Text gets the main value of this row, so how can we get the ID value of the line outside the GridView event?
All in all, the GridView is simply the principle of table, so when we know it, we can do it in TableCell.
The following is the code for the button's onclick event
Button Btsend = sender as Button;
TableCell tc = (TableCell) btsend. Parent;
GridViewRow GVR = (gridviewrow) tc. Parent;
EWebShop.BLL.Order Bllorder = new EWebShop.BLL.Order ();
Bllorder.updateordertextandsendtime (GVR. cells[0]. Text, (TextBox) gvr. FindControl ("Txtordertext")). Text, DateTime.Now);
Response.Redirect (Request.Url.ToString ());
I don't need to talk about it here.
If there is anything wrong, please advise.
Note: The above expansion layer of the JS code is used Meng Xianhua teacher's. ^  _  ^

The effect chart is as follows:
Initial diagram:


The point opening effect is as follows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.