Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Datagrid control

Datagrid control

Scheduled Pinned Locked Moved ASP.NET
csshelptutorialannouncement
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prakash_Mishra
    wrote on last edited by
    #1

    Hi all In a data grid i have two such columns where it acts as a link to a different page. But problem is since i have two response.redirect statements its executing the first one only. My condition is after redirecting to different page i am populating that page with some details( example if i am clicking on cand id 1 then in the next page detail will of cand whose id is 1) so i am using session varible. The code what wrote is If (......I want the condition.....) Then lbCand_Id = e.Item.FindControl("Label5") Session("CAND_ID") = lbCand_Id.Text Response.Redirect("Update_Feedback.aspx") Else lbCand_Id1 = e.Item.FindControl("Label1") Session("Cand_ID1") = lbCand_Id1.Text Response.Redirect("Summary.aspx") End If Pl tel me in if condition what i have to write like datagrid1.item... something like that.so that i can execute both the conditions. Thanks and Regards

    Prakash Mishra(Banglore,India)

    M V I 3 Replies Last reply
    0
    • P Prakash_Mishra

      Hi all In a data grid i have two such columns where it acts as a link to a different page. But problem is since i have two response.redirect statements its executing the first one only. My condition is after redirecting to different page i am populating that page with some details( example if i am clicking on cand id 1 then in the next page detail will of cand whose id is 1) so i am using session varible. The code what wrote is If (......I want the condition.....) Then lbCand_Id = e.Item.FindControl("Label5") Session("CAND_ID") = lbCand_Id.Text Response.Redirect("Update_Feedback.aspx") Else lbCand_Id1 = e.Item.FindControl("Label1") Session("Cand_ID1") = lbCand_Id1.Text Response.Redirect("Summary.aspx") End If Pl tel me in if condition what i have to write like datagrid1.item... something like that.so that i can execute both the conditions. Thanks and Regards

      Prakash Mishra(Banglore,India)

      M Offline
      M Offline
      Member 3879881
      wrote on last edited by
      #2

      Hi in datagrid template column u have the hyper link or outside the grid u have?, If inside the grid u have the hyperlink,then u can access the link using this code: For Each MainGRD As DataGridItem In Me.dgrdmain.Items dim Candid as HyperLink=ctype(maingrd.FindControl("Idofhyperlink"),HyperLink) Next Here candid is the hyperlink now..., U can use ur if condition based on that candid..., Did u got it?,

      Regards, Magi

      P 1 Reply Last reply
      0
      • M Member 3879881

        Hi in datagrid template column u have the hyper link or outside the grid u have?, If inside the grid u have the hyperlink,then u can access the link using this code: For Each MainGRD As DataGridItem In Me.dgrdmain.Items dim Candid as HyperLink=ctype(maingrd.FindControl("Idofhyperlink"),HyperLink) Next Here candid is the hyperlink now..., U can use ur if condition based on that candid..., Did u got it?,

        Regards, Magi

        P Offline
        P Offline
        Prakash_Mishra
        wrote on last edited by
        #3

        hi magi I already wrote the code its working fine my problem is i want to write a condition (if else)so that i can execute my code, Pl see the code in post. So just tell me the if condition. Like suppose i click on the 1 column of the grid some thing like this( datagrid1.item.....) Regards

        Prakash Mishra(Banglore,India)

        M 1 Reply Last reply
        0
        • P Prakash_Mishra

          Hi all In a data grid i have two such columns where it acts as a link to a different page. But problem is since i have two response.redirect statements its executing the first one only. My condition is after redirecting to different page i am populating that page with some details( example if i am clicking on cand id 1 then in the next page detail will of cand whose id is 1) so i am using session varible. The code what wrote is If (......I want the condition.....) Then lbCand_Id = e.Item.FindControl("Label5") Session("CAND_ID") = lbCand_Id.Text Response.Redirect("Update_Feedback.aspx") Else lbCand_Id1 = e.Item.FindControl("Label1") Session("Cand_ID1") = lbCand_Id1.Text Response.Redirect("Summary.aspx") End If Pl tel me in if condition what i have to write like datagrid1.item... something like that.so that i can execute both the conditions. Thanks and Regards

          Prakash Mishra(Banglore,India)

          V Offline
          V Offline
          Vipin d
          wrote on last edited by
          #4

          . why didnt u can use query string for passing candid? In datagrid , create a template column with hyper link like

          <

          																									`<%#DataBinder.Eval(Container.DataItem, "NewsHeading")%>` >  
          

          in c# protected string GetURL (string fldval ) { //here u can make ur if condition string SzOpenwindow=""; SzOpenwindow="javascript:openMywindow('yourpage1.aspx?&id="+ fldval +"','View',500,320)"; return SzOpenwindow; } writa js function openMywindow(url,name,iWidth,iHeight) { var iLeft = (screen.availWidth-500 - iWidth/ 2); var iTop = (screen.availHeight-420 - iHeight / 2); var features; var objwindow; features = "width="+iWidth+",height="+iHeight+",left="+iLeft+",top="+iTop; features += ",screenX="+iLeft+",screenY="+iTop; features += ",scrollbars=1,resizable=0,location=0"; features += ",menubar=0,toolbar=0,status=0"; objwindow = window.open(url,name, features); }

          All I ever wanted is what others have....
          CrazySanker

          1 Reply Last reply
          0
          • P Prakash_Mishra

            hi magi I already wrote the code its working fine my problem is i want to write a condition (if else)so that i can execute my code, Pl see the code in post. So just tell me the if condition. Like suppose i click on the 1 column of the grid some thing like this( datagrid1.item.....) Regards

            Prakash Mishra(Banglore,India)

            M Offline
            M Offline
            Member 3879881
            wrote on last edited by
            #5

            Hi i think this is ur probs..., In datagrid ur displaying the candidate id and his photo..., Based on the candi id selection it want to open another child window and show his details ?, If its yes..., Use this way,. In ur datagrid property bulder select the hyperlink column and there u can see "Url format string", There give some other aspx page form and ur passing parameter..., Means it should eb like this: frmCashflowStatementLink.aspx?candid={0} Then there itself see the "target" dropdown box there u select "-new" Then Go to that child page(for me i have taken this one frmCashflowStatementLink.aspx) In ur pageload not postback method give this code: txtLinkID.Text = Request.QueryString("candid") Then in ur sqladapater query u check with that txtlinkid value..., If its correct display those values like..., This only u asked na?,

            Regards, Magi

            P 1 Reply Last reply
            0
            • P Prakash_Mishra

              Hi all In a data grid i have two such columns where it acts as a link to a different page. But problem is since i have two response.redirect statements its executing the first one only. My condition is after redirecting to different page i am populating that page with some details( example if i am clicking on cand id 1 then in the next page detail will of cand whose id is 1) so i am using session varible. The code what wrote is If (......I want the condition.....) Then lbCand_Id = e.Item.FindControl("Label5") Session("CAND_ID") = lbCand_Id.Text Response.Redirect("Update_Feedback.aspx") Else lbCand_Id1 = e.Item.FindControl("Label1") Session("Cand_ID1") = lbCand_Id1.Text Response.Redirect("Summary.aspx") End If Pl tel me in if condition what i have to write like datagrid1.item... something like that.so that i can execute both the conditions. Thanks and Regards

              Prakash Mishra(Banglore,India)

              I Offline
              I Offline
              Imran Khan Pathan
              wrote on last edited by
              #6

              Give command name property to both link. Like as for link1 CommandName="Link1" and link2 CommandnName="Link2" Now U can use If condition on GridView rowcommand event If(commandName=="Link1") { //code is here for link1 } else if(commandName=="Link2") { //code is here for link2 } Best Regard Pathan

              ---------------------------------------------------

              1 Reply Last reply
              0
              • M Member 3879881

                Hi i think this is ur probs..., In datagrid ur displaying the candidate id and his photo..., Based on the candi id selection it want to open another child window and show his details ?, If its yes..., Use this way,. In ur datagrid property bulder select the hyperlink column and there u can see "Url format string", There give some other aspx page form and ur passing parameter..., Means it should eb like this: frmCashflowStatementLink.aspx?candid={0} Then there itself see the "target" dropdown box there u select "-new" Then Go to that child page(for me i have taken this one frmCashflowStatementLink.aspx) In ur pageload not postback method give this code: txtLinkID.Text = Request.QueryString("candid") Then in ur sqladapater query u check with that txtlinkid value..., If its correct display those values like..., This only u asked na?,

                Regards, Magi

                P Offline
                P Offline
                Prakash_Mishra
                wrote on last edited by
                #7

                Hi magi i just asked the IF condition in vb for the data grid eg if( first column is selected) do some thing else do some thing I want to know in the bracket what i have to write, any r u form bangalore? Regards

                Prakash Mishra(Banglore,India)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups