Primary key will always be an integer, so declare it as: declare intPKID as integer
and also it is not necessary to have the convert.toint32 .... Hth, Karthick -----Original Message----- From: Anna Leon [mailto:[EMAIL PROTECTED] Sent: 15 October 2004 14:52 To: [EMAIL PROTECTED] Subject: RE: [AspNetAnyQuestionIsOk] Populating a Form And what do I declare in this line: intPKID = Convert.ToInt32(dataGrid.DataKeys[gridItem.ItemIndex]) --- Karthick Kumar <[EMAIL PROTECTED]> wrote: > The IF statement will NOT contain the left and right > paranthesis.... > And modify the IF as: > > If (sRBText=cb1.ClientID) Then > cb1.Checked = True > AdvID = i.Cells(4).Text.ToString() > ViewState("advid") = AdvID > Exit For > End if > > Hth, > Karthick > > > -----Original Message----- > From: Sandeep K [mailto:[EMAIL PROTECTED] > Sent: 15 October 2004 14:30 > To: [EMAIL PROTECTED] > Subject: Re: [AspNetAnyQuestionIsOk] Populating a > Form > > > here is its VB.NET equivalent.. > > Dim i As DataGridItem > For Each i In dgUsers.Items > i.ToolTip = "Test" > cb1 = CType(i.FindControl("chkPush"), CheckBox) > cb1.Checked = False > if(sRBText=cb1.ClientID) > { > cb1.Checked = True > AdvID = i.Cells(4).Text.ToString() > ViewState("advid") = AdvID > Exit For > } > Next > > Cheers, > Sandeep > Anna Leon <[EMAIL PROTECTED]> wrote: > > Anyone mind converting to vb.net? That's what I'm > using... > > > --- Amogh Lachake wrote: > > > Hii, > > > > try using something of this sort... > > > > > > foreach(DataGridItem i in dgUsers.Items) > > { > > i.ToolTip = "Test"; > > cb1 = (CheckBox) i.FindControl("chkPush"); > > cb1.Checked = false; > > if(sRBText==cb1.ClientID) > > { > > cb1.Checked = true; > > AdvID = i.Cells[4].Text.ToString(); > > ViewState["advid"] = AdvID; > > break; > > } > > } > > > > > > On Thu, 14 Oct 2004 17:32:34 -0400, Rajendra > Appalla > > wrote: > > > Lets say the button the user presses after the > > user selects the row of > > > the correct address is "btn". > > > > > > btn.Attributes.Add("onclick", "return > > CheckBoxConfirm(this.form);"); > > > > > > You can add a client side java script function > > that checks whether the > > > user checked atleast one check box in the > datagrid > > or not as below: > > > > > > I hope you are using Template columns for the > > checkbox column in the > > > datagrid. Lets say the ID of the checkbox is: > > "chkSelect". > > > > > > function CheckBoxConfirm (frm) > > > { > > > var flag = false; > > > > > > for (i=0; i> > { > > > // Look for our checkboxes > > only > > > if > > (frm.elements[i].name.indexOf('chkSelect') != > > > -1) > > > { > > > // If any are > > checked then confirm > > > alert, otherwise nothing happens > > > > > if(frm.elements[i].checked) > > > { > > > > > flag = true; > > > > > return confirm ('Are you > > > sure you want to delete your selection(s)?') > > > > > > } > > > > > } > > > }// end of for loop. > > > > > > alert('You have to Select at least one > > row. \n\n\n You can > > > Select row(s) by checking corresponding > > CheckBox(es).'); > > > return flag; > > > } > > > > > > > > > You need to make sure that the user selects not > > more than one checkbox. > > > You can tweak above script to do that. > > > > > > I am assuming that you assign the primary key > > field of the table to the > > > DataKeyField property of the datagrid. > > > > > > In the btn_click event, you can get the primary > > key id of the row of > > > which the checkbox is clicked as follows: > > > > > > foreach(DataGridItem gridItem in > > dgTableView.Items) > > > { > > > CheckBox chk = (CheckBox) > > > gridItem.FindControl("chkSelect"); > > > if(chk.Checked) > > > { > > > intPKID = > > > > > > Convert.ToInt32(dataGrid.DataKeys[gridItem.ItemIndex]); > > > break; > > > > > > } > > > } > > > > > > > > > Pass this primary key id to the form and in the > > form query the database > > > to get the values of the columns you need to > > display in the form. > > > > > > Rajendra. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > From: sas0riza [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, October 14, 2004 3:27 PM > > > To: [EMAIL PROTECTED] > > > Subject: [AspNetAnyQuestionIsOk] Populating a > Form > > > > > > > > > Hi, > > > > > > I'm using a search form to find an address. I > then > > return it to the > > > screen in a datagrid. I've added a checkbox > column > > and I want the > > > user to check the correct address and hit a > > button. How do I write > > > the code to see which checkbox was selected? > > > > > > After clicking the button, I want to take the > row > > that the user > > > selected (address) and populate it into a form. > > How do I populate a > > > form from fields in the database? > > > > > > Thanks. > > > > > > > > > > > > > > > > > > > > > Yahoo! Groups Sponsor > > > ADVERTISEMENT > > > click here > > > > > > > > > > > D=groups/S=1705006764:HM/EXP=1097868438/A=2372354/R=0/SIG=12id813k2/*htt > > > > > > ps:/www.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F210 > > > 04SS> > > > > > > > > > > > s/S=:HM/A=2372354/rand=719079343> > > > > > > _____ > > > > > > Yahoo! Groups Links > > > * To visit your group on the web, go to: > > > > > > http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ > > > > > > * To unsubscribe from this group, send an > > email to: > > > > [EMAIL PROTECTED] > > > > > > > > cribe> > > > > > > * Your use of Yahoo! Groups is subject to > > the Yahoo! Terms of > > > Service . > > > > > > > > > [Non-text portions of this message have been > > removed] > > > > > > > > > > > > > > > > > > Yahoo! Groups Sponsor > > > > > > ADVERTISEMENT > > > > > > > > > ________________________________ > > > Yahoo! Groups Links > > > > > > To visit your group on the web, go to: > > > > > > http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ > > > > > > To unsubscribe from this group, send an email > to: > > > > [EMAIL PROTECTED] > > > > > > Your use of Yahoo! Groups is subject to the > Yahoo! > > Terms of Service. > > > > > > > _______________________________ > Do you Yahoo!? > Declare Yourself - Register online to vote today! > http://vote.yahoo.com > > > > > Yahoo! Groups Links > > > > > > > > > > --------------------------------- > Do you Yahoo!? > vote.yahoo.com - Register online to vote today! > > [Non-text portions of this message have been > removed] > > > > > > Yahoo! Groups Links > > > > > > > > > > _______________________________ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com Yahoo! Groups Links ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
