passing client side variable value to server side

 i have a grid and  by click on the rows, the onrowclick event is fired on client side. I want to pass the row index to the server side.

As there are not sessions variables in javascript so i am stuck to pass the row to the server side.. I have made a texbox and set its value

to the index in the onrowclick event but when refresh calls, the text box became empty as the value set is on client side, i want page to persist

the value,  How can i do that? Tel me some way passing the row index to the server side??

0
M
11/5/2008 7:19:41 AM
📁 asp.net.client-side
📃 24353 articles.
⭐ 1 followers.

💬 3 Replies
👁️‍🗨️ 1456 Views

Hi,

You can call GridView_SelectedIndexChanging event on row click event so that you can get the index of the row that is selected

To achieve this you have to add attribute "onclick" to row in GridView_RowDataBound event as

e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GridView, "Select$" + e.Row.RowIndex);


And in GridView_SelectedIndexChanging you can do whatever you want since you are getting the row index


Thanks & Regards,

Omkar A. Lale

"Courage is what it takes to stand up and speak; courage is also what it takes to sit down and listen."

~ Do Mark as Answer if it solves your query ~
0
Omkar
11/5/2008 9:45:06 AM

Hi i have the exact situation ,did u get the solution?

 instead of grid view am usinh asp:repeater control inside a table

something like following

<table style="font-size:small; font-family:Times New Roman;">

<asp:Repeater ID="rpt" runat="server"

DataSourceID="LinqDataSource1" onitemcommand="rpt_ItemCommand">

<ItemTemplate>

 

<tr>

<td style="display:none;"><%# Eval("PK_ID")%>td>

<td>

<a style="cursor:pointer;color:Maroon;" onclick='javascript:return redirectmenu(<%# Eval("PK_ID")%>);return false;'><%# Eval("MENU_NAME")%>a>td>

tr>

ItemTemplate>

 

asp:Repeater>

<asp:LinqDataSource ID="LinqDataSource1" runat="server"

ContextTypeName="EverRecDataContext" Select="new (PK_ID, MENU_NAME, URL)"

TableName="L_MENU_MASTERs"

Where="FK_PARENT_ID == @FK_PARENT_ID && IS_ACTIVE == @IS_ACTIVE">

<WhereParameters>

<asp:Parameter DefaultValue="0" Name="FK_PARENT_ID" Type="Int32" />

<asp:Parameter DefaultValue="1" Name="IS_ACTIVE" Type="Int32" />

WhereParameters>

asp:LinqDataSource>

table>

0
Monalisa
11/5/2008 11:14:15 AM

Hi 

You can write code under the "gridView_SelectedIndexChanged" and you will be able to get the selected row number.

Hope this will solve the issue.

John

0
mejohn
11/5/2008 12:42:59 PM