Sunday, March 11, 2012

pass value to modelopopup dropdown

Can you please post the entire page source code so that we can see how you are stitching this all together?


<body>

<formid="fMrl1"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<div>

<asp:UpdatePanelID="whole"runat="server"><ContentTemplate>

<asp:DataGridID="dg"runat="server"AutoGenerateColumns="False"

CellPadding="4"DataKeyField="err_code_id"

PageSize="15"Width="976px"GridLines=NoneBackColor="LightYellow"BorderColor="Black"BorderStyle="Solid"BorderWidth="3px"Font-Bold="False"Font-Italic="False"Font-Names="Arial"Font-Overline="False"Font-Size="Large"Font-Strikeout="False"Font-Underline="False">

<FooterStyleBackColor="LightYellow"ForeColor="#003399"/>

<ItemStyleBackColor="LightYellow"ForeColor="#003399"/>

<HeaderStyleBackColor="LightYellow"Font-Bold="True"ForeColor="#CCCCFF"Font-Italic="False"Font-Names="Arial Black"Font-Overline="False"Font-Strikeout="False"Font-Underline="False"/>

<Columns>

<asp:BoundColumnDataField="rank"ReadOnly="True"Visible="False"></asp:BoundColumn>

<asp:BoundColumnDataField="finding_id"ReadOnly="True"Visible="False"></asp:BoundColumn>

<asp:BoundColumnDataField="err_code_id"ReadOnly="True"Visible="False"></asp:BoundColumn>

<asp:BoundColumnDataField="type"ReadOnly="True"Visible="False"></asp:BoundColumn>

<asp:BoundColumnDataField="REVIEW_ID"ReadOnly="True"Visible="False"></asp:BoundColumn>

<asp:BoundColumnDataField="REVIEW_NUM"ReadOnly="True"Visible="False"></asp:BoundColumn>

<asp:BoundColumnDataField="SELECTED_FINDING"ReadOnly="True"Visible="False"></asp:BoundColumn>

<asp:TemplateColumnHeaderText=" ">

<ItemTemplate>

<asp:CheckBoxID="Chkerr"runat="server"AutoPostBack="true"checked="false"OnCheckedChanged="RowChanged"/>

</ItemTemplate>

<EditItemTemplate>

<asp:CheckBoxID="Chkerr"runat="server"AutoPostBack="true"Checked='<%# DataBinder.Eval(Container, "DataItem.SELECTED_FINDING") %>'OnCheckedChanged="RowChanged"/>

</EditItemTemplate>

</asp:TemplateColumn>

<asp:BoundColumnDataField="CODE"HeaderText="Err Code"ReadOnly="True">

<HeaderStyleWrap="False"/>

</asp:BoundColumn>

<asp:TemplateColumnHeaderText="Err Amt ">

<ItemTemplate>

<asp:textboxID="txtERR_AMT"runat="server"Width="77px"

/>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumnHeaderText="Billed Codes/Units">

<ItemTemplate>

<asp:TextBoxID="TextBox2"runat="server"Text='<%# DataBinder.Eval(Container, "DataItem.BILLED_CODES_UNITS") %>'Width="102px"></asp:TextBox>

</ItemTemplate>

<ItemStyleWrap="False"/>

<HeaderStyleWrap="False"/>

</asp:TemplateColumn>

<asp:TemplateColumn>

<ItemTemplate>

<asp:LinkButtonID="LinkButton1"runat="server"OnClick="ClientShowModal"Text="Show Modal"/>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumnHeaderText="Correct Codes/Units">

<ItemTemplate>

<asp:TextBoxID="TextBox3"runat="server"Text='<%# DataBinder.Eval(Container, "DataItem.CORRECT_CODES_UNITS") %>'Width="120px"></asp:TextBox>

</ItemTemplate>

<ItemStyleWrap="False"/>

<HeaderStyleWrap="False"/>

</asp:TemplateColumn>

<asp:Templatecolumn>

<ItemTemplate>

<asp:TextBoxID="txtUniqueID"runat="server"CssClass="txtHidden"Text='<%#Eval("err_code_id")%>'Visible="false"/>

</ItemTemplate>

</asp:Templatecolumn>

</Columns>

<PagerStyleBackColor="#99CCCC"ForeColor="#003399"HorizontalAlign="Left"Mode="NumericPages"/>

</asp:DataGrid>

</ContentTemplate>

</asp:UpdatePanel>

<asp:PanelID="NotePopup"runat="server"CssClass="modalPopup"style="Z-INDEX: 108; LEFT: 318px; POSITION: absolute; TOP: 120px"Height="222px"Width="252px">

<DIVstyle="BORDER-LEFT: gray thin; WIDTH: 341px; POSITION: relative; HEIGHT: 246px; BACKGROUND-COLOR: gainsboro">

<asp:Labelid="Label20"style="Z-INDEX: 103; LEFT: 36px; POSITION: absolute; TOP: 6px"runat="server"

Font-Size="12pt"Width="216px"Height="18px"Font-Bold="True">Error Reason</asp:Label>

<asp:Labelid="Label17"style="Z-INDEX: 101; LEFT: 0px; POSITION: absolute; TOP: 0px"runat="server"

Font-Size="12pt"Width="340px"BackColor="White"Height="30px"Font-Bold="True"></asp:Label>

<asp:Labelid="Label1"style="Z-INDEX: 104; LEFT: 12px; POSITION: absolute; TOP: 42px"runat="server"

Width="312px"Height="24px">Select a Error Reason and click OK to Link.</asp:Label>

<asp:DropDownListID="Drpreason_policy"style="Z-INDEX: 105; LEFT: 12px; POSITION: absolute; TOP: 66px"runat="server"DataTextField="Description"DataValueField="id"Width="308px">

</asp:DropDownList>

<asp:Buttonid="cmdlnkOK"style="Z-INDEX: 106; LEFT: 156px; POSITION: absolute; TOP: 210px"

runat="server"Width="72px"Text="OK"></asp:Button>

<asp:Buttonid="cmdLnkCancel"style="Z-INDEX: 107; LEFT: 240px; POSITION: absolute; TOP: 210px"

runat="server"Width="72px"Text="Cancel">

</asp:Button>

</DIV>

</asp:panel>

</div>

<asp:TextBoxID="txtmessage"runat="server"style="z-index: 101; left: 11px; position: absolute; top: 495px"></asp:TextBox>

<ajaxToolkit:ModalPopupExtenderID="notempe"runat="server"BackgroundCssClass="modalBackground"

TargetControlID="FakeNote"PopupControlID="NotePopup"/>

<asp:ButtonID="FakeNote"runat="server"style="display:none; z-index: 102; left: 202px; position: absolute; top: 494px;"/>

<asp:TextBoxID="txtlink"runat="server"Style="z-index: 102; left: 338px; position: absolute;

top: 518px"></asp:TextBox>

</form>

</body>

</html>

onclick = "clientshowmodel" so I can do that on server side and did this on that but even though mydropdown DataSource has list of items, it is not showing on dropdown right now. I am thinking control doesn't find the which dropdown I am trying to fill...

Protected Sub ClientShowModal(ByVal sender As Object, ByVal e As EventArgs)

Dim dgItem As DataGridItem = CType(CType(sender, Control).NamingContainer, DataGridItem)
For Each dgItem In dg.Items
Dim mylink As LinkButton
mylink = CType(dgItem.FindControl("LinkButton1"), LinkButton)
Dim A As String
A = mylink.UniqueID
''''''''''this is fifth row's link button clicked
If A = "dg$ctl05$LinkButton1" Then
notempe.Show()
txtmessage.Text = 14
Dim myDropDown As DropDownList

''''''''''not sure if myform would find this dropdown , it is actually in my model popup panel, but when I put id of that panel it didn't recognized......

myDropDown = CType(myform.FindControl("Drpreason_policy"), DropDownList)
myDropDown.DataSource = Fill_DropDown()
myDropDown.DataBind()

myDropDown.Items.Insert(0, "")
myDropDown.Items.Item(0).Value = ""
myDropDown.SelectedIndex = 0
End If
Next


Are you saying that you get an error on the line that calls the FindControl method? You should be able to reference the dropdown in code behind just by using the control ID, e.g. Drpreason_policy.DataSource = Fill_DropDown().

You could add a CommandArgument value to the LinkButton so that you can retrieve that value in the OnClick event handler and use it to provide context to your method that loads the dropdown.

Jason


actually I don't even have to find control so I took it out. Now, this line Dim test = Drpreason_policy.Items(i).ToString actually gives me value but I have a hard time to insert to my dropdown, how can I do that? my dropdown id is Drpreason_policy
Fill_Dropdown() function returns dataset.

Drpreason_policy.DataSource = Fill_DropDown()
Drpreason_policy.DataBind()
Dim i As Integer
Dim j = Drpreason_policy.Items.Count

For i = 0 To Drpreason_policy.Items.Count - 1
Dim test = Drpreason_policy.Items(i).ToString

Next


I don't really understand the problem. You are calling DataBind on the dropdown...is that not loading the dropdown?


no it is not like I said I can even see the value on test = .....


when I click cancel button on the pop up panel, I can see the panel with items briefly and on the second route when I click linkbutton again this time I can see my items in dropdown. . Why this is happening??

No comments:

Post a Comment