exp1
1.Add one image button in datagrid ,and code the javascript to pop up a model window .
<FooterTemplate>
<IMG style="CURSOR: hand" onclick=javascript:ShowReference(); src="<%=Request.ApplicationPath%>/images/reference.gif">
</FooterTemplate>
<script language="javascript">
function ShowReference(){
//get the skuid from the modaldialog and refresh this page.
var SKU = window.showModalDialog('<%=Request.ApplicationPath%>/OM/FrmSKUReference.aspx', window.document, "dialogWidth:600px;dialogHeight:700px;");
if(SKU.length != null)
{
window.location.href('<%=Request.ApplicationPath%>/OM/FrmOrderItems.aspx');
}
}
</script>
2.in Model window get what u select in DataGrid
aspx:
<!add a hidden var to save the return value.>
<INPUT id="hdCloseWnd" type="hidden" name="hdCloseWnd" runat="server">
<ItemTemplate>
<!add a radiobutton >
<hlcontrols:radiobutton id="rdbProduct" AutoEventWireup="true" AutoPostBack=true text='<%#DataBinder.Eval(Container.DataItem,"ProductSKU").ToString().Trim()%>' runat="Server" onCheckedChanged="Radio_Clicked">
</hlcontrols:radiobutton>
</ItemTemplate>
add javascript ,close the window after getting what u select
<script language="javascript">
//this script block is to set the return value of this search window with the chosen SKU id.
var closeWnd = document.Form1.hdCloseWnd;
window.returnValue = document.Form1.hdCloseWnd.value;
if(closeWnd!=null && closeWnd.value.length > 0)
{
window.close();
}
</script>
cs:
protected void Radio_Clicked(object source, EventArgs e)
{
Herbalife.WebControls.RadioButton rbt = source as Herbalife.WebControls.RadioButton;
Session[SessionKey.SearchCriteriaVO] = null;
Session["SKUid"] = rbt.Text.Trim();
hdCloseWnd.Value = rbt.Text.Trim();
}
3 .In Main WIndow Add some code to get the seesion value when bounding the datagrid
cs:
private void InitializeComponent()
{
this.dgOrderItem.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgOrderItem_ItemCommand);
this.dgOrderItem.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgOrderItem_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
private void dgOrderItem_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Footer)
{
Herbalife.WebControls.TextBox txtNSKU = e.Item.FindControl("txtNSKU") as Herbalife.WebControls.TextBox;
txtNSKU.Text = (string) Session["SKUid"];
Session.Remove("SKUid");
}
}
exp2
Sub WIndow :
aspx:
protected System.Web.UI.HtmlControls.HtmlInputHidden hdCloseWnd;
<script language="javascript">
var closeWnd = document.Form1.hdCloseWnd;
window.returnValue = document.Form1.hdCloseWnd.value;
if(closeWnd!=null && closeWnd.value.length > 0){
window.close();
}
</script>
cs:
protected void Radio_Clicked(object source, EventArgs e)
{
Herbalife.WebControls.RadioButton rbt = source as Herbalife.WebControls.RadioButton;
Session[SessionKey.SearchCriteriaVO] = null;
Session[SessionKey.CustomerID] = rbt.Text.Trim();
hdCloseWnd.Value = rbt.Text.Trim();
}
Main Window:
aspx:
<script language="javascript">
function ShowSearchCust(){
cusID = window.showModalDialog('<%=Request.ApplicationPath%>/OM/FrmSearchCust.aspx', window.document, "dialogWidth:500px;dialogHeight:500px;");
txt = document.getElementById("ucHerbalifeIDControl_txtCustomerID");
if(cusID.length >0)
{
txt.value = cusID;
}
}
</script>
cs:
protected Herbalife.WebControls.ImageButton imglookup;
private void Page_Load(object sender, System.EventArgs e)
{
imglookup.Attributes.Add("onclick","javascript:ShowSearchCust();");
}