Hi,
Here I write some code for getting selected row in data control in javascript
try this
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language ="javascript" >
function as(tid) {
var str = new String();
var g=tid.split('_');
alert("selected Row index is :"+g[2]);
}
</script>
</head>
<body >
<form id="form1" runat="server">
<div>
<asp:datalist id="DataList1" runat="server" width="70%" xmlns:asp="#unknown">
onitemcommand="DataList1_ItemCommand">
<HeaderTemplate >
<table width="100%" align="center" border="1">
</HeaderTemplate>
<itemtemplate>
<tr>
<td>
<asp:button id="Button1" runat="server" text="Button" onclientclick="as(this.id)" />
</td>
</tr>
</itemtemplate>
<footertemplate>
</footertemplate></table>
</div>
</form>
</body>
</html>
The code behind file contains following code
protected void Page_Load(object sender, EventArgs e)
{
List<string> str = new List<string>();
str.Add("sdgfsdfsd");
str.Add("sdgfsdfsd");
str.Add("sdgfsdfsd");
str.Add("sdgfsdfsd");
str.Add("sdgfsdfsd");
str.Add("sdgfsdfsd");
str.Add("sdgfsdfsd");
str.Add("sdgfsdfsd");
str.Add("sdgfsdfsd");
DataList1.DataSource = str;
DataList1.DataBind();
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
}
I hopw you understand what I said
All the Best