Jen

gridview 動態產生 checkbox 判斷核取問題

主要是在GridView的AutoGenerateColumns屬性.

      <asp:Button ID="Button1"  runat="server" 
      Text="Button" onclick="Button1_Click" />
      <asp:GridView ID="GridView1" runat="server" 
      AutoGenerateColumns="false">
         <Columns>
             <asp:TemplateField>
                 <ItemTemplate>
                 </ItemTemplate>
             </asp:TemplateField>
         </Columns>
     </asp:GridView>
CodeBehind
   protected void Page_Init(object sender, EventArgs e)
 {
     GridView1.RowDataBound += 
            new GridViewRowEventHandler(GridView1_RowDataBound);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     dcuserDataContext udc = new dcuserDataContext();
     var vTable = from p in udc.Tabl1
                      select p;
     GridView1.DataSource = vTable;
     GridView1.DataBind();

 }

 void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         CheckBox cb = new CheckBox();
         cb.ID = "cbTest";
         cb.Text = "ttt";
         e.Row.Cells[0].Controls.Add(cb);
     }
 }

 protected void Button1_Click(object sender, EventArgs e)
 {
     foreach (GridViewRow row in GridView1.Rows)
     {
         if (row.RowType == DataControlRowType.DataRow)
         {
             CheckBox cb = 
                   ((CheckBox)row.Cells[0].FindControl("cbTest"));
             Response.Write(cb.Checked.ToString() + "<br />");
         }

     }
 }

初始狀態

a

當按下藍色框的按鈕POST BACK之後,

結果Response.Write()出來

b

20 意見:

  匿名

2010年2月19日 上午11:51

Frame on Our Muffled Prices at www.Pharmashack.com, The Foremost [b][url=http://www.pharmashack.com]Online Dispensary [/url][/b] To [url=http://www.pharmashack.com]Buy Viagra[/url] Online ! You Can also Balance Prime Deals When You [url=http://www.pharmashack.com/en/item/cialis.html]Buy Cialis[/url] and When You You [url=http://www.pharmashack.com/en/item/levitra.html]Buy Levitra[/url] Online. We Also Be subjected to a Ginormous Generic [url=http://www.pharmashack.com/en/item/phentermine.html]Phentermine[/url] Championing the profit of Your Edibles ! We Manumit up Mark raise up [url=http://www.pharmashack.com/en/item/viagra.html]Viagra[/url] and Also [url=http://www.pharmashack.com/en/item/generic_viagra.html]Generic Viagra[/url] !

  匿名

2010年3月9日 下午10:49

Hi Guys,Just registered here and looking to have a great time. I am looking for the best cash gifting program out there in the internet. Can you guide me?

Below are some sites that I found and I am not sure how much they are going to help me.
[url=http://www.squidoo.com/Residual-Cash-Forever-Cash-Gifting-System]cash gifting[/url]
[url=http://www.squidoo.com/Residual-Cash-Forever-Cash-Gifting-System]join cash gifting[/url]
[url=http://www.squidoo.com/Residual-Cash-Forever-Cash-Gifting-System]best cash gifting program[/url]

  匿名

2013年2月14日 下午8:04

A fascinating discussion is worth comment. I think that you need to write more about this
issue, it might not be a taboo subject but generally people do not speak about such subjects.
To the next! Best wishes!!

my web blog :: free ipad giveaway 2011

  匿名

2013年2月14日 下午8:15

I've been browsing on-line greater than three hours as of late, but I never discovered any fascinating article like yours. It's
pretty value sufficient for me. In my view, if
all website owners and bloggers made excellent
content as you probably did, the web might be much more helpful than ever before.


My site Penisadvantage

  匿名

2013年2月14日 下午8:34

Wonderful goods from you, man. I have understand your stuff previous to and you're just extremely wonderful. I really like what you've acquired here, really like what you are
saying and the way in which you say it. You make it enjoyable and you still take care of to
keep it sensible. I can't wait to read much more from you. This is really a terrific website.

Feel free to surf to my web site - magic of making up review amazon

  匿名

2013年2月14日 下午8:37

Does your blog have a contact page? I'm having a tough time locating it but, I'd like to shoot you an email.

I've got some suggestions for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it grow over time.

My web page :: linksedu.com

  匿名

2013年2月14日 下午8:38

My relatives all the time say that I am wasting my time here at net, however
I know I am getting knowledge all the time by reading such good articles.


Feel free to surf to my weblog :: best portable dvd players for children
My web site :: audiovox portable dvd player reviews,best budget portable dvd player reviews,best buy portable dvd player reviews,best cheap portable dvd player reviews,best dual portable dvd player reviews,best portable dual screen dvd player reviews,best portable dvd player,best portable dvd player battery life,best portable dvd player car headrest,best portable dvd player cnet,best portable dvd player comparison,best portable dvd player deals,best portable dvd player dual screen,best portable dvd player for car,best portable dvd player for car dual screen,best portable dvd player for car headrest,best portable dvd player for car reviews,best portable dvd player for children,best portable dvd player for kids,best portable dvd player for kids in car,best portable dvd player for plane,best portable dvd player for the car,best portable dvd player for the money,best portable dvd player for toddler,best portable dvd player reviews,best portable dvd player reviews 2010,best portable dvd player reviews 2011,best portable dvd player reviews 2012,best portable dvd player to buy,best portable dvd player uk,best portable dvd players,best portable dvd players 2012,best portable dvd players battery life,best portable dvd players cnet,best portable dvd players for automobiles,best portable dvd players for car,best portable dvd players for car dual screen,best portable dvd players for children,best portable dvd players for kids,best portable dvd players for kids reviews,best portable dvd players for the car,best portable dvd players reviews,best portable dvd players under 100,best portable dvd players walmart,best portable dvd players with long battery life,consumer reports best portable dvd player,consumer reports best portable dvd players,dual screen portable dvd player reviews,durabrand portable dvd player reviews,insignia portable dvd player reviews,magnavox portable dvd player reviews,mintek portable dvd player reviews,panasonic portable dvd player reviews,portable dvd player reviews,portable dvd player reviews 2011 uk,portable dvd player reviews battery life,portable dvd player reviews car,portable dvd player reviews cnet,portable dvd player reviews consumer reports,portable dvd player reviews uk,sony portable dvd player reviews,the best portable dvd player reviews,toshiba portable dvd player reviews

  匿名

2013年2月14日 下午8:46

Howdy I am so grateful I found your webpage, I really found you by accident, while I was looking on Askjeeve
for something else, Anyways I am here now and would just like to
say many thanks for a marvelous post and a all round enjoyable blog
(I also love the theme/design), I don't have time to read through it all at the moment but I have saved it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the excellent work.

my web page - socialbookmarkingss.info
My site: http://dbchase.com/

  匿名

2013年2月14日 下午8:48

I'm really enjoying the design and layout of your site. It's a very
easy on the eyes which makes it much more enjoyable for me to come here and visit
more often. Did you hire out a developer to create your theme?
Outstanding work!

my homepage :: wikifollow.info

  匿名

2013年2月14日 下午9:36

With havin so much content do you ever run into any problems of plagorism or copyright violation?

My blog has a lot of exclusive content I've either written myself or outsourced but it seems a lot of it is popping it up all over the web without my authorization. Do you know any ways to help reduce content from being stolen? I'd truly appreciate
it.

My blog :: Dubturbo Review Yahoo

  匿名

2013年4月8日 上午5:32

Your own write-uρ features established benеfiсial to myѕelf.

It’s verу uѕeful and you're simply clearly extremely educated in this field. You have got exposed my personal eye in order to various thoughts about this particular matter using intriguing, notable and solid content material.

Also visit my page: Schapedia.Com
Look into my web-site ... phentermine

  匿名

2013年4月9日 上午2:46

Yοur poѕt featureѕ verified nеcessary to
me pегѕonаlly. It’s quite informative
anԁ yοu're naturally very well-informed in this region. You get opened our sight to different opinion of this specific subject using intriquing, notable and sound content.

Here is my site :: http://versicherungs-wiki.de/index.php/Viagra
My web-site buy viagra

  匿名

2013年4月12日 下午3:38

Your cuггеnt articlе features confirmed
necessаry to mе. It’s rеallу hеlpful аnd you really arе nаtuгally veгy knowledgеаble of this
type. Yоu havе gοt expoѕed ouг eye tο bе able to numerous thοughts about this spеcіfiс
subject uѕing intriguing, notable and ѕtrοng contеnt matеrial.


Check out my blog :: meridia online
My web-site - meridia online

  匿名

2013年4月12日 下午7:28

Your own write-up features pгοven usеful to
myself. It’s еxtremely educatiοnal and you're simply certainly really educated of this type. You have got opened my own eye to be able to various views on this kind of subject along with intriguing, notable and reliable content.

Have a look at my blog post :: phentermine
Check out my blog post - phentermine

  匿名

2013年4月18日 下午1:27

Your current rеpοrt featureѕ proven necеsѕary to us.

It’s vеrу helpful and you're simply clearly really well-informed in this field. You get opened up my face to be able to numerous views on this kind of subject using intriguing, notable and reliable content material.

My homepage - Buy meridia
Feel free to surf my blog : meridia

  匿名

2013年4月19日 下午5:51

Your οwn post fеatures νerifіed nеceѕsarу to
myself. It’s rеаlly helρful аnd you're simply obviously extremely well-informed in this area. You get popped my personal sight for you to numerous thoughts about this specific matter together with intriquing, notable and reliable content.
Feel free to visit my webpage :: teamprometheus.org

  匿名

2013年5月25日 下午5:46

Hello! I just would like to give a huge thumbs up for the nice data you’ve got here on this post.
I might be coming again to your weblog for more soon.



Also visit my weblog - a good website for ringtones

  匿名

2013年5月26日 下午1:30

Hiya! I just wish to give an enormous thumbs up for the good information you could have right here on this post.

I can be coming back to your blog for extra soon.

my web-site ... funny campaign slogans for president

  匿名

2013年5月26日 下午5:12

Your current post provideѕ proven helpful to mе.
It’s extгemely useful and you're simply clearly really educated in this region. You possess opened up my face in order to varying views on this subject together with intriguing, notable and reliable content.

my web-site :: buy Klonopin