We can use this type of functionality to make user more sure about his decision
eg. If i am showing some car related information in grid like car model make brand total users color and price now if some customer is interested in my car and he wants to see some more details then just clicking on "Show complete details" that perticular row expand without post back and show some more details like power HP, fuel type, Registration year etc.
So lets begin....
-first we need DataGrid with templateField
-Now customize that templateField and and one panel into it called pnl
-now on that panel add one link button named as mylink
-and add other information below that link
something like this...
<asp:TemplateField HeaderText="Other Details">
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server" Height="16px" style="OVERFLOW: hidden"
Width="376px" Wrap="False">
Car Model :
<a ID="mylink" runat="server" href="#" onclick="showdetails(this)">View Complete
Car Details</a><br />
OtherDetails :
<asp:Label ID="Label5" runat="server" Text='<%# Eval("OtherDetails") %>'></asp:Label>
<br />
Registration City :
<asp:Label ID="Label2" runat="server" Text='<%# Eval("RegistrationCity") %>'></asp:Label>
<br />
Registration Date :
<asp:Label ID="Label3" runat="server" Text='<%# Eval("RegistrationDate") %>'></asp:Label>
<br />
Current Location :
<asp:Label ID="Label4" runat="server" Text='<%# Eval("CurrentLocationCity") %>'></asp:Label>
<br />
Phone: 2300000000<br />
Mobile: 9800000000
<br />
For the best quote, refer to Yash Car Auto when calling!</asp:Panel>
</ItemTemplate>
I have some labels which bind with my table values you can change as per you requirement
ok we done with dataGrid
now we have to show row expanded at client end without post back for that we need to use java script
we have already bind link's onclick event to some function called "showdetails" and we pass parameter as this hence we can access our link button inside that function for chage
now write function inside java script
<script language="javascript" type="text/javascript">
function showdetails(ctrl)
{
pnl = ctrl.getAttribute("ID");
pnl = pnl.substring(0,pnl.indexOf("mylink")-1);
pnl = pnl + "_Panel1";
if(ctrl.innerText == "View Complete Car Details")
{
ctrl.innerText = "Hide Complete Car Details";
document.getElementById(pnl).style.height="130px";
document.getElementById(pnl).style.width="400px";
}
else
{
ctrl.innerText="View Complete Car Details";
document.getElementById(pnl).style.height="16px";
document.getElementById(pnl).style.width="300px"; }
}
</script>
now in this function get whole control now we need to find our control and access. For this we can use "ctrl.getAttribute("ID")" using this we can traverse all control inside that template control hence and check for link now once we find link change its innerText(caption) and change size of panel(pnl) using "document.getElementById(pnl).style.height" and width i change because we can have column size small at the start but on click we can show big column with more details in it.




MultiQuote




|