Create Look up Page Data Bound
//Opener Page (Look Up page)
Step 1 : Add following script in Lookup.aspx page
// Lookup.aspx
<script language="javascript" type="text/javascript">
function
GetRowValue(val)
{
if(val != ' ')
{
val1 = 0;
window.opener.document.getElementById('ctl00_ContentPlaceHolder1_hdfID').value = val;
window.opener.document.getElementById('ctl00_ContentPlaceHolder1_hdfFlagID').value =
val1;
}
window.opener.document.forms[0].submit();
self.close();
}
</script>
// in code behinds lookup.aspx.cs
Step2 : InGridView- Go to edit item template in grid and
select the button field and convert as item template field and command name as ‘select’
Step3 : Add below
code
protected void grdDetails_RowDataBound(object
sender, GridViewRowEventArgs e)
{
if
((e.Row.RowType == DataControlRowType.DataRow))
{
//((LinkButton)e.Row.FindControl("LinkButton1")).Attributes.Add("onclick",
"javascript:GetRowValue('" + e.Row.Cells[1].Text.ToString().Trim() +
"')");
((LinkButton)e.Row.FindControl("LinkButton1")).Attributes.Add("onclick", "javascript:GetRowValue('"
+ DataBinder.Eval(e.Row.DataItem, "ID") + "')");
}
}
//Data Bound Page ()
// Samplepage.aspx
Step1 : Add Looup Button
on Lookup Button click (onclientclick=openpopup())
step2 :Add following Script in abc.aspx
function
OpenPopup()
{
window.open("Lookups/samplelookup.aspx","List","scrollbars=yes,resizable=yes,width=600,height=450");
return false;
}
Step3 : Add the following
two Hidden Fileds for Databound
<asp:HiddenField ID="hdfID" runat="server"
/>
<asp:HiddenField ID="hdfFlagID"
runat="server"
/>
Step 4 : in abc.aspx.cs
page, on Page_load event addthe following code
//samplepage.aspx.cs
if
(hdfID.Value.Trim() != ""
&& hdfFlagID.Value == "0")
{
Fillgrid();
}
protected void Fillgrid()
{
lblresult.Text = "";
string
obid = hdfID.Value;
hdfFlagID.Value = "1";
DataSet
ds = cmn.getopeningbalrecord(obid);
DataRow
dr = ds.Tables[0].Rows[0];
ddlMonth.SelectedValue = dr["obmonth"].ToString();
ddlYear.SelectedValue = dr["obyear"].ToString();
ddldepartment.SelectedValue = dr["DepartmentID"].ToString();
}
Comments
Post a Comment