Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.25 KB | None | 0 0
  1. <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
  2. <ContentTemplate>
  3. <asp:DataList ID="outerDataList" runat="server" OnItemDataBound="outerRep_ItemDataBound">
  4. <ItemTemplate>
  5. <div id="div1" runat="server" visible='<%# ((string)Eval("Code")) != "BABRB" %>'>
  6. <asp:Label ID="lblBABProdType" Font-Size="Medium" Font-Bold="true" runat="server" Text='<%# Eval("Name") %>' style="padding-left:20px" />
  7. <asp:DataList ID="innerDataList" runat="server" RepeatColumns="3" DataKeyField="ProductID" >
  8. <ItemTemplate>
  9. <div id="div4" runat="server" visible='<%# ((string)Eval("ProductCode")) == "BABBE" %>'>
  10. <table ID="table4" runat="server" align="left" width="80%" style="margin-left:30px; font-size:smaller">
  11. <tr>
  12. <td width="3%">
  13. <asp:CheckBox ID="bevCheckBox" runat="server" AutoPostBack="true"
  14. OnCheckedChanged="chkBox_CheckedChanged"/>
  15. </td>
  16. <td align="left" width="7%">
  17. <asp:ImageButton ID="bevImgBtn" runat="server" width="40" height="40" align="middle"
  18. ImageUrl='<%# "~/ProductImages/"+Eval("Image1FileName").ToString() %>'
  19. OnClick="ImgBtn_Click" CommandArgument='<%# Eval("ProductID") %>'/>
  20. </td>
  21. <td valign="middle" width="70%">
  22. <span class="ProductName">
  23. <asp:LinkButton ID="bevLnkBtn" runat="server" OnClick="LnkBtn_Click" CssClass="BABProductName"
  24. CommandArgument='<%# Eval("ProductID") %>'>
  25. <%# DataBinder.Eval(Container.DataItem, "Name")%>
  26. <br /></asp:LinkButton>
  27. </span>
  28. <span class="ProductPrice">
  29. <%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}")%>
  30. </span
  31. <asp:TextBox ID="bevQtyTxtBox" runat="server" Text="Qty: " Font-Size="XX-Small"
  32. Width="40px" ViewStateMode="Disabled"/>
  33. </td>
  34. </tr>
  35. </table>
  36. </div>
  37. <div id="div5" runat="server" visible='<%# ((string)Eval("ProductCode")) == "BABFO" %>' >
  38. <table ID="table5" runat="server" align="left" width="80%" style="margin-left:30px; font-size:smaller">
  39. <tr>
  40. <td width="3%">
  41. <asp:CheckBox ID="foodCheckBox" runat="server" AutoPostBack="true"
  42. OnCheckedChanged="chkBox_CheckedChanged"/>
  43. </td>
  44. <td align="left" width="7%">
  45. <asp:ImageButton ID="foodImgBtn" runat="server" width="40" height="40" align="middle"
  46. ImageUrl='<%# "~/ProductImages/"+Eval("Image1FileName").ToString() %>'
  47. OnClick="ImgBtn_Click" CommandArgument='<%# Eval("ProductID") %>'/>
  48. </td>
  49. <td valign="middle" width="70%">
  50. <span class="ProductName">
  51. <asp:LinkButton ID="foodLnkBtn" runat="server" OnClick="LnkBtn_Click" CssClass="BABProductName"
  52. CommandArgument='<%# Eval("ProductID") %>'>
  53. <%# DataBinder.Eval(Container.DataItem, "Name")%>
  54. <br /></asp:LinkButton>
  55. </span>
  56. <span class="ProductPrice">
  57. <%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}")%>
  58. </span>
  59. <asp:TextBox ID="foodQtyTxtBox" runat="server" Text="Qty: " Font-Size="XX-Small"
  60. Width="40px" ViewStateMode="Disabled"/>
  61. </td>
  62. </tr>
  63. </table>
  64. </div>
  65. </ItemTemplate>
  66. </asp:DataList>
  67. </div>
  68. <br />
  69. </ItemTemplate>
  70. </asp:DataList>
  71. </ContentTemplate>
  72. </asp:UpdatePanel>
  73.  
  74. protected void Page_Load(object sender, EventArgs e)
  75. {
  76. PopulateData();
  77. }
  78.  
  79. private void PopulateData()
  80. {
  81. // Retrieve list of products
  82. string categoryID = Request.QueryString["BABCategoryID"];
  83. // set the stored procedure name
  84. SqlConnection sqlConn = new SqlConnection(ChocolateExpConfiguration.DbConnectionString);
  85. SqlCommand sqlComm = new SqlCommand("GetBABProductsInCategory", sqlConn);
  86. sqlComm.CommandType = CommandType.StoredProcedure;
  87. SqlDataAdapter adptr = new SqlDataAdapter(sqlComm);
  88. sqlComm.Parameters.AddWithValue("@BABCategoryID", categoryID);
  89. DataSet ds = new DataSet();
  90. adptr.Fill(ds);
  91. ds.Relations.Add(new DataRelation("CodeRelation", ds.Tables[0].Columns["Code"], ds.Tables[1].Columns["ProductCode"]));
  92. outerDataList.DataSource = ds.Tables[0];
  93. outerDataList.DataBind();
  94. }
  95.  
  96. protected void outerRep_ItemDataBound(object sender, DataListItemEventArgs e)
  97. {
  98. if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
  99. {
  100. DataRowView drv = e.Item.DataItem as DataRowView;
  101. DataList innerDataList = (DataList)e.Item.FindControl("innerDataList");
  102. innerDataList.DataSource = drv.CreateChildView("CodeRelation");
  103. innerDataList.DataBind();
  104. }
  105.  
  106. }
  107.  
  108. protected void chkBox_CheckedChanged(object sender, EventArgs e)
  109. {
  110. foreach (DataListItem parentItem in outerDataList.Items)
  111. {
  112. //Find nested items(DataList) of parent Datalist
  113. DataList innerDataList = (DataList)parentItem.FindControl("innerDataList");
  114. foreach (DataListItem childItem in innerDataList.Items)
  115. {
  116. CheckBox bevCheckBox = (CheckBox)childItem.FindControl("bevCheckBox");
  117. CheckBox foodCheckBox = (CheckBox)childItem.FindControl("foodCheckBox");
  118. TextBox bevQtyTxtBox = (TextBox)childItem.FindControl("bevQtyTxtBox");
  119. TextBox foodQtyTxtBox = (TextBox)childItem.FindControl("foodQtyTxtBox");
  120. if ((bevCheckBox.Checked == true) || (foodCheckBox.Checked == true))
  121. {
  122. bevQtyTxtBox.Visible = true;
  123. foodQtyTxtBox.Visible = true;
  124. }
  125. else
  126. {
  127. bevQtyTxtBox.Visible = false;
  128. foodQtyTxtBox.Visible = false;
  129. }
  130. UpdatePanel1.Update();
  131. }
  132. }
  133. }*
  134.  
  135. {
  136.  
  137. int count = int.Parse(GridView1.Rows.Count.ToString());
  138.  
  139. for (int i = 0; i < count; i++)
  140. {
  141.  
  142. CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
  143. CheckBox cb1 = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox2");
  144. CheckBox cb2 = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox3");
  145. TextBox tb = (TextBox)GridView1.Rows[i].Cells[4].FindControl("txtration");
  146. TextBox tb1 = (TextBox)GridView1.Rows[i].Cells[5].FindControl("txtjob");
  147. TextBox tb2 = (TextBox)GridView1.Rows[i].Cells[6].FindControl("txtaadhar");
  148.  
  149.  
  150. if (cb.Checked == true)
  151. {
  152. tb.Visible = true;
  153.  
  154. }
  155. else
  156. {
  157. tb.Visible = false;
  158.  
  159.  
  160. }
  161. if (cb1.Checked == true)
  162. {
  163. tb1.Visible = true;
  164.  
  165. }
  166. else
  167. {
  168. tb1.Visible = false;
  169.  
  170. }
  171. if (cb2.Checked == true)
  172. {
  173. tb2.Visible = true;
  174.  
  175. }
  176. else
  177. {
  178. tb2.Visible = false;
  179.  
  180.  
  181. }
  182.  
  183.  
  184. }
  185. }
  186.  
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement