得得撸改名得得爱 javascript能否取得GridView中的一行值?
来源:网络整理 时间:2016/7/8 13:14:27 关键词:得得撸改名得得爱
关于网友提出的“得得撸改名得得爱 javascript能否取得GridView中的一行值?”问题疑问,本网通过在网上对“得得撸改名得得爱 javascript能否取得GridView中的一行值?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题:得得撸改名得得爱 javascript能否取得GridView中的一行值?
描述:
<>
DataSourceID="ObjectDataSource1" Width="100%" CellPadding="4" ForeColor="#333333">
protected void Page_Load(object sender, EventArgs e)
{
if (Request["id"] != null)
{
SqlConnection c />
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();
}
}
}
}
解决方案3: 以下的js代码循环取GridView所有值,当然也可以取某一行的值:
解决方案4: 可以的
以下作参考
function onRowCbCheck(cb,rowNewsID) {
var obj = document.getElementById("txtNewsIds");
if (cb.checked) {
obj.value += rowNewsID + ",";
}
else {
obj.value = obj.value.replace(","+rowNewsID + ",", ",");
}
}
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 + ")");
}
}
解决方案5: 能实现,一行的值是什么值?
以上介绍了“得得撸改名得得爱 javascript能否取得GridView中的一行值?”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2416507.html