将GridView值传递给会话 [英] Passing a GridView Value to a Session

查看:101
本文介绍了将GridView值传递给会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人身体



我试图将一个值从GridView传递到TextBox或会话。

 会话[  SEmpID] = GridView1.SelectedRow.FindControl(< span class =code-string>  SubjectID)。ToString();  





  TXTTest.Text = GridView1.SelectedRow.FindControl(  SubjectID)。ToString();  



但我总是记得错误:

对象引用未设置为对象的实例。



我希望任何人都可以解决它。



谢谢

解决方案

GridView1.SelectedRow.FindControl(SubjectID ) null

当你试图施放 null ToString(),您将收到错误。



试着找出为什么 GridView1.SelectedRow.FindControl(SubjectID)没有返回任何内容。






1)你的代码是否在GridView1_SelectedIndexChanged()事件中。



2)如果你在 page_load()事件中设置GridView DataSource

那么它应该在



  if (!IsPostBack){GridView1.DataSource =   xyzDataset} 







请将其标记为ans&如果你觉得它有帮助你。

谢谢

Asp.Net/C#.Net帮助 [ ^ ]

Hemant Singh


Hi Every body

I am trying to pass a value form a GridView to a TextBox or a session.

Session["SEmpID"] = GridView1.SelectedRow.FindControl("SubjectID").ToString();


or

TXTTest.Text = GridView1.SelectedRow.FindControl("SubjectID").ToString();


But I always recive the error:
Object reference not set to an instance of an object.

I hope any one can solve it to me.

Thank you

解决方案

GridView1.SelectedRow.FindControl("SubjectID") is null.
When you try to cast null to ToString(), you will get an error.

Try to find out why GridView1.SelectedRow.FindControl("SubjectID") is not returning anything.


Hi,

1) Is your given code in GridView1_SelectedIndexChanged() event.

2) Where you set GridView DataSource
if it is in page_load() event then it should be in

if (!IsPostBack) { GridView1.DataSource = "xyzDataset" }




Please mark it as ans & rate if you find it helps you.
Thank You
Asp.Net/C#.Net Help[^]
Hemant Singh


这篇关于将GridView值传递给会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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