Gridview Doesn't Refresh After CheckedChanged? - asp.net

I have a gridview with Template field. I add a checkbox in templatefield . Autopostback is true for checkbox .
I fill grid in Load-page and creted column dynamic .
if (!IsPostBack)
{
FillGrid();
}
I use update panel
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<SharePoint:SPGridView ID="grid" AllowSorting="true" AllowFiltering="true" CssClass="ms-listviewtable"
runat="server" AutoGenerateColumns="false">
<RowStyle CssClass="ms-alternating" Height="10px" />
<Columns>
<asp:TemplateField>
<ItemTemplate >
<asp:CheckBox ID="select" runat="server"
OnCheckedChanged="select_CheckedChanged" AutoPostBack="true" />
<input id="Display" type="hidden" runat="server" />
<input id="itemID" type="hidden" runat="server" />
<asp:Image ID="icon" runat="server" Height="10px" Visible="false" />
</ItemTemplate>
<ItemStyle Width="35px" />
</asp:TemplateField>
<asp:TemplateField >
</asp:TemplateField>
</Columns>
</SharePoint:SPGridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="select" EventName="OnCheckedChanged" />
</Triggers>
</asp:UpdatePanel>
but show error :A control with ID 'select' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.
My problem is : When checkbox is change, page refresh
I don't want to refresh page after checkedchange!

you have to set autopostback="false" or remove autopostback property in checkbox. autopostback actully refresh the page.

So what happens if you set the autopostback property of the checkbox to false?
Also if you are actually looking to handle the onchange event of the checkbox you could wrap the grid with an UpdatePanel; the user wouldn't see a postback but you still get the flexibility of serverside event handling.

First of all you need changes templetecolumn as below
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkselect" runat="server" />
<input id="Display" type="hidden" runat="server" />
<input id="itemID" type="hidden" runat="server" />
<asp:Image ID="imgicon" runat="server" Height="10px" Style="display: none;" ImageUrl="~/images/arrow_left.jpg" />
</ItemTemplate>
<ItemStyle Width="35px" />
</asp:TemplateField>
Now handle itemdatabound event in server side code
Protected Sub SPGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvBanner.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim chkselect As CheckBox = e.Row.FindControl("chkselect")
Dim imgicon As Image = e.Row.FindControl("imgicon")
If chkselect IsNot Nothing Then
chkselect.Attributes.Add("onclick", "javascript:DoMyTask(this,'" + imgicon.ClientID + "')")
End If
End If
End Sub
Now specify JavaScript function in aspx page as below.
<script type="text/javascript" language="javascript">
function DoMyTask(obj, imgid) {
var objCheck = obj.checked;
var objimg = document.getElementById(imgid)
if (objCheck == true) {
objimg.style.display = "block";
//set more attributes over here
}
else {
objimg.style.display = "none";
//set more attributes over here
}
var count = $(":checkbox:checked").length;
alert('you have selected ' + count + ' Rows');
}
</script>
Hope this will help you...happy coding ..

Related

PopupControlExtender inside Gridview not closing

A GridView will list rows which have to be approved/rejected. First column is named 'Action', which when clicked will display the ajax popupcontrolextender panel with two links (Approve/Reject). After the link is clicked, I need to update the status in the DB & refresh the GridView. ObjectDataSource is used to Bind the GridView. I have used the below code inside RowCommand event:
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim gvRow As GridViewRow = GridView1.Rows(index)
If e.CommandName = "Approve" Then
BusinessLogicLayer.UpdateFileStatus(sID, Approve)
ElseIf e.CommandName = "Reject" Then
BusinessLogicLayer.UpdateFileStatus(sID, Reject)
End If
GridView1.DataBind()
DirectCast(gvRow.FindControl("pceMenu"), AjaxControlToolkit.PopupControlExtender).Cancel()
HTML of the TemplateField 'Action':
<asp:TemplateField HeaderText="Action" >
<ItemTemplate>
<ajax:PopupControlExtender ID="pceMenu" runat="server" TargetControlID="imgMenu" PopupControlID="pnlMenu" Position="Right" >
</ajax:PopupControlExtender>
<asp:Image ID="imgMenu" runat="server" ImageUrl="~/Images/gear.png" CssClass="popupImage" />
<asp:Panel ID="pnlMenu" runat="server" CssClass="popupControl" Width="85px" Height="50px" style="display:none;">
<div class="menu-row" style="border-top: none;">
<asp:Image ID="imgApprove" runat="server" ImageUrl="~/Images/tick.png" style="float:left;"/>
<asp:LinkButton ID="lnkApprove" runat="server" Text="Approve" ToolTip="Approve" style="margin-left:10px;" CommandName="Approve" />
</div>
<div class="menu-row">
<asp:Image ID="imgReject" runat="server" ImageUrl="~/Images/delete16.png" style="float:left;"/>
<asp:LinkButton ID="lnkReject" runat="server" Text="Reject" ToolTip="Reject" style="margin-left:10px;" CommandName="Reject" />
</div>
</asp:Panel>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left"/>
<ItemStyle HorizontalAlign="Center" Width="5%"/>
</asp:TemplateField>
Tried the below methods, but no success:
Suppress the panel's visibility using style="display:'';"
Called the Cancel() method of the PopupControlExtender
Note: The pop-up disappears if I don't bind the GridView inside the RowCommand event. But, I need to refresh the results displayed after Approve/Reject.
Appreciate any help. Thanks!
Hi you can hide ajax control toolkit's modal popup extender from code behind try this code:
IdOfYourModelPopup.Hide();

GridView rowcommand event is not working in updatepanel

I have a GridView inside an UpdatePanel which fires the RowCommand event. While firing the RowCommand event i assign the e.CommandArgument value to a label but it does not show the effect. I set breakpoint over the event during execuation it set the label text property but after getting out of the event, The label lost its value and went to its previous text. I stored the value in ViewState and Session but still it did not work. Below is my code.
The GridView1_RowCommand event here want to assign value to lblValue which is the problem
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
lblValue.Text = e.CommandArgument.ToString();
}
}
Here i want to delete the record from the database through the label value
protected void Button2_Click(object sender, EventArgs e)
{
Int32 id = Convert.ToInt32(lblValue.Text);
conn.RegionalBusinessUnits.Remove(conn.RegionalBusinessUnits.Where(rbu => rbu.Id == id).FirstOrDefault());
conn.SaveChanges();
}
This is the markup
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div class="BoxStyle" >
<div class="header"><asp:HyperLink ID="hlBack" runat="server"><img src="../images/back-icon.png" alt="Go Back" height="20" width="20" style="vertical-align: middle; text-align: center; cursor: pointer;" /></asp:HyperLink> Regional Department Unit List</div>
<div id="myModal" class="reveal-modal">
<h1>Delete</h1>
<p>This will guide you through the delete process</p>
<asp:Label ID="lblValue" runat="server" Text="Label"></asp:Label>
<p><asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" /></p>
<a class="close-reveal-modal">×</a>
</div>
<div class="contents">
<center>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="RBUEntityDataSource" CssClass="gridview" OnRowCommand="GridView1_RowCommand" EnableViewState="False">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Region" HeaderText="Region" ReadOnly="True" SortExpression="Region" />
<asp:TemplateField HeaderText="Update">
<ItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CommandName="Update" OnClick="lbUpdate_Click">Update</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lbDelete" class="big-link" data-reveal-id="myModal" runat="server" CommandName="Delete" CommandArgument='<%# Eval("Id") %>' OnClick="lbDelete_Click">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:EntityDataSource ID="RBUEntityDataSource" runat="server" ConnectionString="name=ChemonicsDBEntities" DefaultContainerName="ChemonicsDBEntities" EnableFlattening="False" EntitySetName="RegionalBusinessUnits" Select="it.[Id], it.[Region]" OrderBy="it.[Id] asc" Where="it.[DeletedBy] = 0">
</asp:EntityDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</center>
</div>
<div class="bottom"></div>
</div>
lblValue isn't being updated as it is outside UpdatePanel1. If you move your UpdatePanel1 with ContentTemplate up to directly under the ScriptManager, it should work. Be sure to also put the
</ContentTemplate>
</asp:UpdatePanel>
at the very bottom.
You can then remove the Trigger and change the UpdatePanel "UpdateMode" to "Always"
<asp:GridView runat="server" ID="gvDocuments" AutoGenerateColumns="false"
AllowPaging="true" PageSize="10" DataKeyNames="DocumentID">
<Columns>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:Button ID="btnDocumentViewAttachmentInGrid" runat="server" Text="View Attachment" CommandName="ViewAttachment" CausesValidation="false" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
My button click I was trying to stream a file to the client, but got the error "Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed." since I was on an update panel. I tried registering the datagridview for postback, nothing worked. Finally, in the code, I tried this:
Protected Sub gvDocuments_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvDocuments.RowCreated
Try
If (e.Row.RowType = DataControlRowType.DataRow) Then
Dim btnDocumentViewAttachmentInGrid As Button = e.Row.FindControl("btnDocumentViewAttachmentInGrid")
btnDocumentViewAttachmentInGrid.CommandArgument = e.Row.RowIndex.ToString()
ScriptManager1.RegisterPostBackControl(btnDocumentViewAttachmentInGrid)
End If
Catch ex As Exception
'handle error here
End Try
End Sub
...and then I could stream the file like this:
Protected Sub gvDocuments_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvDocuments.RowCommand
Try
If e.CommandName = "Select" Then
gvDocuments.SelectedIndex = e.CommandArgument
ElseIf e.CommandName = "ViewAttachment" Then
Dim iDocumentID As Int64 = gvDocuments.DataKeys(e.CommandArgument).Value
Dim oRows() As DataRow = dtDocs.Select("DocumentID = " & iDocumentID.ToString())
If oRows.Length > 0 Then
Dim oRow As DataRow = oRows(0)
Dim strFileName As String = oRow("NetworkPath").ToString()
Dim strJustTheName As String = oRow("DocumentID").ToString() & "." & oRow("FileNameExtension").ToString()
strFileName &= strJustTheName
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", String.Format("attachment;filename=""{0}""", strJustTheName))
Response.TransmitFile(strFileName)
Response.Flush()
Response.End()
End If
End If
Catch ex As Exception
'handle error
End Try
End Sub
...and BOOM goes the dynamite, totally works! :)
In this case not, but may be you add control to GridView with same ID, You must have unique ID.
I had this problem, and it worked
on Page_Load must be rebinding the gridview like this
If (!Page.IsPostBack)
{
bindhere()
}

ASP.NET How to show AjaxControlToolkit Modal Popup from CheckBox

I need to show an AjaxControlToolkit ModalPopupExtender control, when user checks/unchecks a CheckBox control that is inside a GridView as a TemplateField.
-- Updated on 24/05/2013
See final solution here...
We finally solved the problem. So I decided to post here the complete solution and the final code.
The GridView
<asp:GridView ID="gvDocs" runat="server" CssClass="grid" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
OnPageIndexChanging="gvDocs_PageIndexChanging"
OnSorting="gvDocs_Sorting"
OnRowDataBound="gvDocs_RowDataBound">
<AlternatingRowStyle CssClass="grid_row_alternate"/>
<HeaderStyle CssClass="grid_header" />
<RowStyle CssClass="grid_row" />
<SelectedRowStyle CssClass="grid_row_selected" />
<Columns>
<asp:BoundField DataField="ID"/>
<asp:BoundField DataField="COLUMN_A" SortExpression="COLUMN_A" HeaderText="COLUMN_A" />
<asp:BoundField DataField="COLUMN_B" SortExpression="COLUMN_B" HeaderText="COLUMN_B" />
<!-- TemplateField with the CheckBox and the ModalPopupExtender controls -->
<asp:TemplateField HeaderText="Check" SortExpression="CHECK_COLUMN">
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"/>
<!-- Modal Popup block -->
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground" DropShadow="True" TargetControlID="CheckBox1" PopupControlID="panModalPopup" CancelControlID="CancelButton"/>
<asp:Panel ID="panModalPopup" runat="server" style="display:none; text-align:left; width:400px; background-color:White; border-width:2px; border-color:#40A040; border-style:solid; padding:10px;">
Are you sure?
<br /><br />
<div style="text-align:right;">
<asp:Button ID="ConfirmButton" runat="server" Text="Confirm" OnClick="ConfirmButton_Click" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>'/>
<asp:Button ID="CancelButton" runat="server" Text="Cancel"/>
</div>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
The code behind
protected void gvDocs_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType.Equals(DataControlRowType.DataRow))
{
// Setting the CheckBox check reading the state from DB
CheckBox CheckBox1 = (CheckBox)e.Row.FindControl("CheckBox1");
CheckBox1.Checked = DataBinder.Eval(e.Row.DataItem, "CHECK_COLUMN").ToString() == "Y"; // Or any other value that works like true/false
}
}
protected void ConfirmButton_Click(object sender, EventArgs e)
{
string id = ((Button)sender).CommandArgument; // Get the ID column value
// Update the CHECK_COLUMN value on the DB or do whatever you want with the ID...
BindData(); // Method that do the GridView DataBind after the changes applied to the DB
}
Some things to know
1) The ModalPopupExtender1 control is inside the GridView TemplateField because it needs to have access to the CheckBox1 and its click event. It's probably not the best solution ever, but it works and so it would not affect to much on performance if your GridView is not too complicated and if it is paged.
2) In order to catch the ConfirmButton Click event, you have to remove the OKControlID property from the ModalPopupExtender control settings.
-- END
-- Updated on 22/05/2013
Then I need the ID of the corresponding row to make an UPDATE on the DB.
-- END
This is the GridView
<asp:GridView ID="gvDocs" runat="server" CssClass="grid" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
OnPageIndexChanging="gvDocs_PageIndexChanging"
OnSorting="gvDocs_Sorting"
OnRowDataBound="gvDocs_RowDataBound">
<AlternatingRowStyle CssClass="grid_row_alternate"/>
<HeaderStyle CssClass="grid_header" />
<RowStyle CssClass="grid_row" />
<SelectedRowStyle CssClass="grid_row_selected" />
<Columns>
<asp:BoundField DataField="ID_DOCUMENTO" Visible="False"/>
<asp:BoundField DataField="NUM_PROT" SortExpression="NUM_PROT" HeaderText="N. Prot." />
<asp:BoundField DataField="DATE_PROT" SortExpression="DATE_PROT" HeaderText="Data Prot." />
... some other BoundFields ...
<asp:TemplateField HeaderText="Da archiviare" SortExpression="DA_ARCHIVIARE">
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:CheckBox ID="chkArchiviare" runat="server" AutoPostBack="True" OnCheckedChanged="chkArchiviare_CheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
And this is the ModalPopup block
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow="True" TargetControlID="panModalPopup" PopupControlID="panModalPopup" OkControlID="btnConferma" CancelControlID="btnAnnulla" />
<asp:Panel ID="panModalPopup" runat="server" style="display:none; width:400px; background-color:White; border-width:2px; border-color:Black; border-style:solid; padding:20px;">
Are you sure?
<br /><br />
<div style="text-align:right;">
<asp:Button ID="btnConferma" runat="server" Text="Conferma" OnClick="btnConferma_Click"/>
<asp:Button ID="btnAnnulla" runat="server" Text="Annulla" OnClick="btnAnnulla_Click" />
</div>
</asp:Panel>
Now, I want to show the ModalPopup each time a checkbox is checked/unchecked and that popup have to show a confirmation message with 2 buttons: Confirm and Cancel.
Confirm have to do an update on the DB and then postback.
Cancel have only to hide the popup without postback.
I know that ModalPopupExtender listens to OnClick events. So, do I necessary need a Button, LinkButton, ImageButton, etc. or can I do what I want?
You are right, it listens to onclick events, but client-side ones, so, the target control of the extender can be anything you can click on, even a div or a label.
try to show/hide ModalPopupExtender1 from chkArchiviare_CheckedChanged event like this.
ModalPopupExtender1.show();
and
ModalPopupExtender1.hide();
take one Hidden button and make it as TargetControlID like this.
<asp:HiddenField ID="btnHiddenDtl1" runat="Server" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow="True" TargetControlID="btnHiddenDtl1" PopupControlID="panModalPopup" OkControlID="btnConferma" CancelControlID="btnAnnulla" />
you need not to call cancel button click event to hide ModalPopupExtender1.
You no need to include ModalPopup Extender inside your GridView. You can bind check box control in template field in GridView and use OnCheckedChanged property in it...So template would be like below
<asp:TemplateField HeaderText="Da archiviare" SortExpression="DA_ARCHIVIARE">
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:CheckBox ID="chkArchiviare" runat="server"
OnCheckedChanged="chkArchiviare_CheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>
After this you have to call show function on chkArchiviare_CheckedChanged event...like this
ModalPopupExtender1.Show();
Here ModalPopupExtender1 is ID of you ModalPopupExtender control.
One more thing you have to remember use one button on .aspx page. And pass this button ID into ModalPopupExtender TargetControlID... Like this
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow="True"
TargetControlID="btnShowModalPopup" PopupControlID="panModalPopup"
OkControlID="btnConferma" CancelControlID="btnAnnulla" />
<asp:Panel ID="panModalPopup" runat="server" style="display:none; width:400px;
background-color:White; border-width:2px; border-color:Black; border-
style:solid; padding:20px;"> Are you sure?<br /><br />
<div style="text-align:right;">
<asp:Button ID="btnConferma" runat="server" Text="Conferma"
OnClick="btnConferma_Click"/>
<asp:Button ID="btnAnnulla" runat="server" Text="Annulla"
OnClick="btnAnnulla_Click" />
</div>
</asp:Panel>
Here Why Iam using this button?....There is no use of this button because we are using show() in codebehind...but if we are not pass button Id to ModapPopupExtender TargetControlId property. It will give you an error.
So using ModalPopupExtender in this way...you can use it with LinkButton, Label, Button. For more details with example, you can check the below link....
How to Use ModalPopup Extender into GridView
I hope this article will clear your all doubts....Enjoy and share this with others...Thanks!

updatepanel conditionalmode not working

inside updatepanel condtional mode i am not able to enable/disable my button.
</asp:ToolkitScriptManager><asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<div class="buttons"><asp:Button ID="btnReturn" runat="server" Text="Return to Policy" onclick="btnReturn_Click" /> <asp:Button ID="lnkbtnEndorse" runat="server" Text="Import Data" onclick="lnkbtnEndorse_Click" />
<asp:Button ID="btnCompareTop" runat="server" Text="Compare"
onclick="Compare_Click" Enabled="false" />
<asp:Button ID="btnAdditionalInfoOpen" runat="server" Text="Additional Information" /> <asp:Button ID="Button3" runat="server" Text="Save" onclick="SaveCopy_Click" /></div> </ContentTemplate>
</asp:UpdatePanel>
i want to enable compare button in cs page.
code behind
grdNewEndorsement.AutoGenerateColumns = false;
grdNewEndorsement.DataBind();
this.Button1.Enabled = true;
this.btnCompareTop.Enabled = true;
Now button is enabled but btnAdditionalInfoOpen button is not opening pop up window
$('#ctl00_Main_btnAdditionalInfoOpen').click(function () {
$('#additional-info').dialog('open');
return false;
});
If the UpdatePanel's UpdateMode is "Conditional" and ChildrenAsTriggers is "false", you can(have to) update it manually:
this.btnCompareTop.Enabled = true;
UpdatePanel5.Update();
UpdatePanel.Update Method

generate onclick event in image control in asp.net

i am have one datalist in asp.net
i m using vb with asp
now my code is just as follow
<table border="0" cellpadding="0" cellspacing="0" >
<tr>
<br />
<td>
Question Number:
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Question_no") %>' />
<br />
Cust_id:
<asp:Label ID="Cust_idLabel" runat="server" Text='<%# Eval("Cust_id") %>' />
<br />
Question:
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Question") %>' />
<br />
Time:
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Date_time") %>' />
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/ImagesFolde/Chrysanthemum.jpg" Height="50" Width="50" **OnClientClick="s()"**/>
all this in datalist as you can see
so it will be repeated..
i have put one image in it
now i want call a method when any image will be clicked
i make one sub called s() in vb
i want to call it
i use on clientclick() event but doesn't work
what to do?
you use onclientclick - have you made your functions with javascript/jquery ? ( the server side won't be fired)
for instance :
if you call you client method like this :
OnClientClick="return myFunction();"
then your function should be in the header as follows:
<script type=text/javascript>
function myFunction()
{
alert("activated here");
}
</script>
Suppose you have a datalist:
ASPX:
<asp:DataList id="ItemsList" OnItemCommand="Item_Command" runat="server">
<ItemTemplate>
<asp:LinkButton id="SelectButton" Text="Select" CommandName="ModifyRow"
runat="server" CommandArgument='<%#Eval("Id")%>' />
</ItemTemplate>
</asp:DataList>
VB (Code Behind) :
Here I am taking the id from '<%#Eval("Id")%>' and binding some products in bulleted list:
Protected Sub ItemsList_ItemCommand _
(source As Object, e As RepeaterCommandEventArgs) _
Handles Categories.ItemCommand
If e.CommandName = "ModifyRow" Then
' Determine the CategoryID
Dim categoryID As Integer = Convert.ToInt32(e.CommandArgument)
' Get the associated products from the ProudctsBLL and
' bind them to the BulletedList
Dim products As BulletedList = _
CType(e.Item.FindControl("ProductsInCategory"), BulletedList)
Dim productsAPI As New ProductsBLL()
products.DataSource = productsAPI.GetProductsByCategoryID(categoryID)
products.DataBind()
End If
End Sub
<asp:ImageButton ID="imgexpand" runat="server" ImageAlign="Bottom" ImageUrl="~/img/plus.png" OnClick="s" />
you do not need the () in the control onclick statement
this will fire the sub s() procedure in the vb code

Resources