在gridview中插入多行??? [英] multiple rows inserting in gridview???

查看:78
本文介绍了在gridview中插入多行???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何单击gridview外部使用的按钮来更新多行??



gridview中的每一行都具有

1.一个问题-(从数据库绑定)
2.一个答案-(为此使用一个文本框)


我已经在Google上搜索过,但没有结果..


怎么做?

如果有人可以提供帮助??

谢谢问候....

how to update multiple rows on click of the button used outside the gridview???



where each row in gridview is having

1. A question- (which is binded from the database)
2. an answer- (for this a textbox is used)


i have searched on google but with no results..


how can it be done??

if someone can help???

thanks regards....

foreach (GridViewRow row in gvpostslambook.Rows)
{
LinkButton lbtnpostslambook = (LinkButton)row.FindControl("lbtnargument");
TextBox txtanswer = (TextBox)row.FindControl("txt");
prpobj.questionid = Convert.ToInt32(lbtnpostslambook.CommandArgument);
prpobj.answer = txtanswer.Text.Trim();
mainobj.postslambook(prpobj);
}



prp.questionid的值在gridview中的每一行都出现了,但是文本框的值没有出现....

并感谢您回答了我....

但是我的朋友
撒拉雅
我没有从数据库中获取文本框的值..
我只是在使用文本框插入相应的答案
问题...

您的代码显示我应该从数据库中将文本绑定到循环中的文本框,但是除了那些问题之外,我没有从数据库中得到任何东西....

我仍然不知道我的代码有什么问题!!!



the value for the prp.questionid is comming for each row in gridview but the value of the textbox is not comming....

and thanks that you answered me....

but my friend
thatraja
i am not getting the values of the textbox from the database..
i am just using the textboxes to insert the answers for the corresponding
questions...

your code showing that i should bind the text to the textbox in the loop from the database but i am getting nothing from the database except those questions....

i still do not know whats the problem with my code!!!

推荐答案

| steeve_richard写道

|如果您能告诉我如何编辑我的信息,请..
|然后说出来,因为我只能看到改进的问题链接.


这是用于编辑帖子的链接.

对于您的问题

对于gridview中的模板项目,一旦完成数据绑定,则应通过循环分配值.
例子
|steeve_richard wrote

|and plz if you can tell me how to edit my post..
|then tell because i can only see improve question link..


that''s the link for editing your post.

For Your issue

For template items in gridview, once you did databind then you should assign the values through loop.
example
gvEmp.DataSource = dtEmployee;
gvEmp.DataBind();
for (int i = 0; i < dtEmployee.Rows.Count; i++)
{
 for (int j = 1; j < dtEmployee.Columns.Count; j++)
 {
  if (j == 1 || j == 2 || j == 3)
  {
   ((TextBox)(gvEmp.Rows[i].Cells[j].Controls[1])).Text = dtEmployee.Rows[i][j].ToString();
  }
 }
}

因此请根据您的需要更改代码

so change the code based on your need


最合理的方法是修改数据源以包含新数据,然后重新绑定.



您应该编辑自己的帖子,而不是发布虚假的答案".

无论数据来自何处,都需要对其进行更新以包括所需的行,然后将数据与新行绑定.我不明白这段代码与您的问题有何关系.

如果答案不是来自您的数据库,为什么要将它们绑定到网格?在这种情况下,您应该创建一个带有答案的问题集合,将其构建在内存中,然后绑定到该问题.
The most logical way to do this, is to modify your data source to contain the new data, and then rebind.



You should edit your post, not post fake ''answers''.

Where-ever your data comes from, you need to update it to include the rows you want, then bind the data with the new rows. I don''t understand how this code is related to your question.

If the answers do not come from your db, why are you binding them to a grid ? In that case, you should create a collection of questions with answers, build it in memory, and bind to that.


这篇关于在gridview中插入多行???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆