< asp:DataGrid ID="dgdPackageDetails" Runat="server" width="100%" AllowSorting="False" GridLines="None" AutoGenerateColumns="False" >
< Columns >
< asp:TemplateColumn >
< HeaderTemplate >
Date
< /HeaderTemplate >
< ItemTemplate >
< a title="< %# DataBinder.Eval(Container.DataItem,"Date","{0:d}")% > " href="#" onclick="displayPackageDeatils()" >
< %# DataBinder.Eval(Container.DataItem,"Date","{0:d}")% >
< /a >
< /ItemTemplate >
< /asp:TemplateColumn >
< asp:TemplateColumn >
< HeaderTemplate >
Name
< /HeaderTemplate >
< ItemTemplate >
< a title="< %# DataBinder.Eval(Container.DataItem,"Name")% > " href="#" onclick="displayPackageDeatils()" >
< %# DataBinder.Eval(Container.DataItem,"Name")% >
< /a >
< /ItemTemplate >
< /asp:TemplateColumn >
< /Columns >
< /asp:DataGrid >
/***************************************************************************
Name : displayPackageDeatils
Parameters : None
Purpose : To display the contents of the grid in the respective controls
***************************************************************************/
function displayPackageDeatils()
{
var objForm=document.frmPackageInput; // frmPackageInput is the id of the form
objForm.txtDate.value=trimAll(event.srcElement.parentNode.parentNode.cells(0).innerText) //where txtDate is id of a textbox
objForm.txtPackageName.value= trimAll(event.srcElement.parentNode.parentNode.cells(1).innerText)//where txtPackageName is id of a textbox
}
/***************************************************************************
Name : trimAll
Parameters : The string that is to be trimmed
Purpose : To perform both left and right trim of a given string
***************************************************************************/
function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}
Subscribe to:
Post Comments (Atom)
5 comments:
what is Container.DataItem
it will display data from grid to Controles or Reverse..?
It will display data from grid to controls
Container.DataItem is a data binding statement which produces a string output based on the value of the particular database column name.
Container.DataItem is a data binding statement which produces a string output based on the value of the particular database column name.
Post a Comment