<asp:GridView ID="gvProClass" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource1" Width="100%" CellPadding="4" ForeColor="#333333">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="Title" HeaderText="产品类别名" SortExpression="Title">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="PcImg" HeaderText="产品类别图片" SortExpression="PcImg">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30%" />
</asp:BoundField>
<asp:TemplateField HeaderText="【编 辑】" SortExpression="Id">
<ItemStyle HorizontalAlign="Center" Width="14%" />
<ItemTemplate>
<input id="btnEditor" type="button" value="【编 辑】" class="btn" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>我想点击编辑时用javascript将这一行的值赋值给指定的文本框。能不能实现?在不用Ajax的情况下。
解决方案 »
- 三层中出现接口层时如何将各层串起来
- 给个文本编辑控件
- 如何在子页面更改模板页中使用的用户控件中某控件的值
- 大家用2005建项目时候,用新建网站还是新建asp.net应用程序?
- 不好意思小弟向大家求助DATAGRID中单击选中一行以后,该行的数值传递给CHECKBOXLIST.
- thickbox在ie6下的一个bug,请帮忙解决
- 求:点击Datagrid页眉标头进行排序的Javascript代码,顶者有分
- 在打开一个流文件时,总是显示"打开"或"保存",当我点"打开"时,总是以默认的dreamweaver打开,困惑中?????
- sql语句?????
- 问ajaxpro的一个获取值的小问题
- 数据库恢复问题
- 关于error statusCode谁能多教点儿这方面的知识给我啊
以下作参考function onRowCbCheck(cb,rowNewsID) {
var obj = document.getElementById("txtNewsIds");
if (cb.checked) {
obj.value += rowNewsID + ",";
}
else {
obj.value = obj.value.replace(","+rowNewsID + ",", ",");
}
}<asp:GridView ID="gvListNews" Width="98%" HorizontalAlign="Center" runat="server"
OnRowDataBound="gvListNews_RowDataBound" AutoGenerateColumns="False"
BorderColor="Silver" BorderWidth="1px">
<RowStyle Height="25px" />
<Columns>
<asp:TemplateField HeaderText="序号" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
ItemStyle-Width="30px">
<HeaderTemplate>
<asp:CheckBox ID="cbAll" runat="server" onclick="CheckAll(this)" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="cbRow" runat="server" />
<!--上面CheckBox,看后台RowDataBound-->
<asp:HiddenField ID="txtRowID" runat="server" Value='<%# Eval("NID") %>' />
</ItemTemplate>
<FooterTemplate></FooterTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="30px"></ItemStyle>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
没有数据!
</EmptyDataTemplate>
</asp:GridView>protected void gvListNews_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
String newsID = gvListNews.DataKeys[e.Row.RowIndex].Value.ToString(); CheckBox cb = (CheckBox)e.Row.FindControl("cbRow");
cb.Attributes.Add("onclick", "onRowCbCheck(this," + newsID + ")");
}
}
<script language="javascript" type="text/javascript">
function getGridViewData()
{
var gv = document.getElementById("<%=GridView1.ClientID%>");
var rowStr = "";
for (var i = 1; i < gv.rows.length-1; i++) {
var myRow = gv.rows(i);
for (var j = 0; j < myRow.cells.length; j++) {
rowStr += myRow.cells(j).innerText + "/";
}
alert(rowStr);
rowStr = "";
}
return false;
}
</script>
用个CheckBox吗?
$("#GridViewID tr").each(function() {
var item = $(this)
var checkBox = item.find('>td>input:checkbox');
if (checkBox) {
if (checkBox.is(':checked')) {
dosomething;
}
}
})
AJAXLoadProgressForm.aspx:<script src="JS/jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
function ShowProgressDiv() {
var ID = $("input#idtxt").val();
$.ajax({
type: "GET",
url: "GetGridViewByConditionForm.aspx",
data: "id=" + ID,
beforeSend: function() {
$("div#ProgressDiv").css("display", "block");
},
success: function(msg) {
$("div#ShowSearchResult").html(msg);
var html = $("div#ShowSearchResult div#div1").html();
$("div#ShowSearchResult").empty();
$("div#ShowSearchResult").html(html);
$("div#ShowSearchResult>div>table#gvData tr").not(":first-child").hover(function() {
$(this).css("cursor","pointer");
}, function() {
$(this).removeAttr("style");
}).click(function() {
var arr = new Array();
$(this).children("td").each(function() {
arr.push($(this).text());
});
alert(arr.valueOf());
});
},
complete: function() {
$("div#ProgressDiv").css("display", "none");
}
});
}
</script>
<form id="form1" runat="server">
<div style="cursor:hand">
<input type="text" id="idtxt" name="idtxt" />
<input type="button" id="LoadBtn" value="LoadDataGridView" onclick="ShowProgressDiv()" />
</div>
<div id="ProgressDiv" style="display:none">
<img alt="Loading" src="Images/ajax-loader.gif" />Loading......
</div>
<div id="ShowSearchResult">
</div>
</form>
GetGridViewByConditionForm.aspx: <div id="div1">
<asp:GridView ID="gvData" runat="server">
</asp:GridView>
</div>
protected void Page_Load(object sender, EventArgs e)
{
if (Request["id"] != null)
{
SqlConnection conn=null;
SqlCommand cmd = null;
SqlDataAdapter adapter = null;
try
{
conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
conn.Open();
cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
String cmdStr = "select * from dbo.Customers";
if (Request["id"].ToString()!=String.Empty)
{
cmdStr += " where CustomerID= '" + Request["id"].ToString() + "'";
}
cmd.CommandText = cmdStr;
adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
this.gvData.DataSource = ds;
this.gvData.DataBind();
}
catch
{
Response.Write("Error happend!");
Response.Flush();
Response.End();
}
finally
{
if (adapter != null)
{
adapter.Dispose();
}
if (cmd != null)
{
cmd.Dispose();
}
if ((conn != null) && (conn.State == ConnectionState.Open))
{
conn.Close();
}
}
}
}
http://www.cnblogs.com/chenping-987123/archive/2010/08/27/1809877.html