Advertisement

06.19.2008 at 11:57AM PDT, ID: 23500104
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

Default value for textbox in formview

Asked by rbunkofske in Programming for ASP.NET

Tags: , ,

Still new to the .net
I am tring to move fields from a gridview row (I can get the data) to a bound formview fields. Then enter additional fields and insert data into new table bound to the formview.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
Code follows
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
              DataKeyNames="AssignmentID" DataSourceID="SqlDataSource2" Visible="False" 
              Width="652px"
              selectedindex="0"
              onselectedindexchanged="MGridView_SelectedIndexChanged" Height="157px">
              <Columns>
                  <asp:CommandField ShowSelectButton="True" />
                  <asp:BoundField DataField="AssignmentID" HeaderText="AssignmentID" 
                      InsertVisible="False" ReadOnly="True" SortExpression="AssignmentID" 
                      Visible="False" />
                  <asp:BoundField DataField="WorkPeriod" HeaderText="WorkPeriod" 
                      SortExpression="WorkPeriod" />
                  <asp:BoundField DataField="Employee" HeaderText="Employee" 
                      SortExpression="Employee" />
                  <asp:BoundField DataField="Shift" HeaderText="Shift" SortExpression="Shift" />
                  <asp:BoundField DataField="Level" HeaderText="Level" SortExpression="Level" />
                  <asp:BoundField DataField="Area" HeaderText="Area" SortExpression="Area" />
                  <asp:BoundField DataField="Boss" HeaderText="Boss" SortExpression="Boss" />
                  <asp:BoundField DataField="Role" HeaderText="Role" SortExpression="Role" />
              </Columns>
          </asp:GridView>
            </td>
        </tr>
        <tr valign="top">
          <td class="storyLeft" style="width: 258px">
          <p> <a href="#" class="capsule"><strong></strong></a></p>          </td>
          <td>
            <p> <a href="#" class="capsule"></a> <a href="#"></a></p>          </td>
        </tr>
        <tr valign="top">
          <td class="storyLeft" style="width: 258px">
            <p> <a href="#" class="capsule"></a> <a href="#"></a> 
          <asp:Label ID="Message" runat="server"></asp:Label>
              </p>          </td>
          <td>
            <p> <a href="#" class="capsule"></a> <a href="#"></a>
              <asp:Label ID="Message2" runat="server"></asp:Label>
              </p>          </td>
        </tr>
      </table>
     <div class="feature">         
    
      
      <p style="width: 700px"><br />  
          <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
              ConnectionString="<%$ ConnectionStrings:SunshineConnectionString %>" 
              SelectCommand="SELECT * FROM [ShiftAssignments] WHERE ([Boss] = @Boss) ORDER BY [Employee]">
              <SelectParameters>
                  <asp:Parameter DefaultValue = "Dan Clark" Name="Boss" Type="String" />
              </SelectParameters>
          </asp:SqlDataSource>
        </p>
          
          <p> 
              <a href="#" class="capsule"></a>
              <br />
          </p>          
          
          <p> 
              <asp:FormView ID="FormView1" runat="server" DataKeyNames="TimeSheetID" 
                  DataSourceID="SqlDataSource3" DefaultMode="Insert" Width="351px">
                  <EditItemTemplate>
                      TimeSheetID:
                      <asp:Label ID="TimeSheetIDLabel1" runat="server" 
                          Text='<%# Eval("TimeSheetID") %>' />
                      <br />
                      workperiod:
                      <asp:TextBox ID="workperiodTextBox" runat="server" 
                          Text='<%# Bind("workperiod") %>' />
                      <br />
                      tsdate:
                      <asp:TextBox ID="tsdateTextBox" runat="server" Text='<%# Bind("tsdate") %>' />
                      <br />
                      job_description:
                      <asp:TextBox ID="job_descriptionTextBox" runat="server" 
                          Text='<%# Bind("job_description") %>' />
                      <br />
                      Level:
                      <asp:TextBox ID="LevelTextBox" runat="server" Text='<%# Bind("Level") %>' />
                      <br />
                      workarea:
                      <asp:TextBox ID="workareaTextBox" runat="server" 
                          Text='<%# Bind("workarea") %>' />
                      <br />
                      workplace:
                      <asp:TextBox ID="workplaceTextBox" runat="server" 
                          Text='<%# Bind("workplace") %>' />
                      <br />
                      grade:
                      <asp:TextBox ID="gradeTextBox" runat="server" Text='<%# Bind("grade") %>' />
                      <br />
                      days:
                      <asp:TextBox ID="daysTextBox" runat="server" Text='<%# Bind("days") %>' />
                      <br />
                      contract:
                      <asp:TextBox ID="contractTextBox" runat="server" 
                          Text='<%# Bind("contract") %>' />
                      <br />
                      shift:
                      <asp:TextBox ID="shiftTextBox" runat="server" Text='<%# Bind("shift") %>' />
                      <br />
                      reg:
                      <asp:TextBox ID="regTextBox" runat="server" Text='<%# Bind("reg") %>' />
                      <br />
                      ot1:
                      <asp:TextBox ID="ot1TextBox" runat="server" Text='<%# Bind("ot1") %>' />
                      <br />
                      ot2:
                      <asp:TextBox ID="ot2TextBox" runat="server" Text='<%# Bind("ot2") %>' />
                      <br />
                      holes:
                      <asp:TextBox ID="holesTextBox" runat="server" Text='<%# Bind("holes") %>' />
                      <br />
                      hole_length:
                      <asp:TextBox ID="hole_lengthTextBox" runat="server" 
                          Text='<%# Bind("hole_length") %>' />
                      <br />
                      powder:
                      <asp:TextBox ID="powderTextBox" runat="server" Text='<%# Bind("powder") %>' />
                      <br />
                      bolts_4:
                      <asp:TextBox ID="bolts_4TextBox" runat="server" Text='<%# Bind("bolts_4") %>' />
                      <br />
                      bolts_6:
                      <asp:TextBox ID="bolts_6TextBox" runat="server" Text='<%# Bind("bolts_6") %>' />
                      <br />
                      safety:
                      <asp:TextBox ID="safetyTextBox" runat="server" Text='<%# Bind("safety") %>' />
                      <br />
                      equipment:
                      <asp:TextBox ID="equipmentTextBox" runat="server" 
                          Text='<%# Bind("equipment") %>' />
                      <br />
                      employee:
                      <asp:TextBox ID="employeeTextBox" runat="server" 
                          Text='<%# Bind("employee") %>' />
                      <br />
                      employee_number:
                      <asp:TextBox ID="employee_numberTextBox" runat="server" 
                          Text='<%# Bind("employee_number") %>' />
                      <br />
                      <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                          CommandName="Update" Text="Update" />
                      &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                          CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                  </EditItemTemplate>
                  <InsertItemTemplate>
                      Work Period:
                      <asp:TextBox ID="workperiodTextBox" runat="server" 
                          Text='<%# Bind("workperiod") %>' />
                      <br />
                      Date:
                      <asp:TextBox ID="tsdateTextBox" runat="server" Text='<%# Bind("tsdate") %>' />
                      <br />
                      Job Description:
                      <asp:TextBox ID="job_descriptionTextBox" runat="server" 
                          Text='<%# Bind("job_description") %>' />
                      <br />
                      Level:
                      <asp:TextBox ID="LevelTextBox" runat="server" Text='<%# Bind("Level") %>' />
                      <br />
                      Work Area:
                      <asp:TextBox ID="workareaTextBox" runat="server" 
                          Text='<%# Bind("workarea") %>' />
                      <br />
                      Work Place:
                      <asp:TextBox ID="workplaceTextBox" runat="server" 
                          Text='<%# Bind("workplace") %>' />
                      <br />
                      Grade:
                      <asp:TextBox ID="gradeTextBox" runat="server" Text='<%# Bind("grade") %>' />
                      <br />
                      Day's Pay:
                      <asp:CheckBox ID="daysTextBox" runat="server" Text='<%# Bind("days") %>' />
                      Contract:
                      <asp:CheckBox ID="contractTextBox" runat="server" 
                          Text='<%# Bind("contract") %>' />
                      <br />
                      Shift:
                      <asp:TextBox ID="shiftTextBox" runat="server" Text='<%# Bind("shift") %>' />
                      <br />
                      Regular:
                      <asp:TextBox ID="regTextBox" runat="server" Text='<%# Bind("reg") %>' />
                      <br />
                      Over Time 1:
                      <asp:TextBox ID="ot1TextBox" runat="server" Text='<%# Bind("ot1") %>' />
                      <br />
                      Over Time 2:
                      <asp:TextBox ID="ot2TextBox" runat="server" Text='<%# Bind("ot2") %>' />
                      <br />
                      Holes:
                      <asp:TextBox ID="holesTextBox" runat="server" Text='<%# Bind("holes") %>' 
                          Width="35px" />
                      Hole Length:
                      <asp:TextBox ID="hole_lengthTextBox" runat="server" 
                          Text='<%# Bind("hole_length") %>' Width="40px" />
                      <br />
                      Powder:
                      <asp:TextBox ID="powderTextBox" runat="server" Text='<%# Bind("powder") %>' />
                      <br />
                      Bolts 4&quot;:
                      <asp:TextBox ID="bolts_4TextBox" runat="server" Text='<%# Bind("bolts_4") %>' 
                          Width="45px" />
                      Bolts 6&quot;:
                      <asp:TextBox ID="bolts_6TextBox" runat="server" Text='<%# Bind("bolts_6") %>' 
                          Width="40px" />
                      <br />
                      Safety:
                      <asp:CheckBox ID="safetyTextBox" runat="server" Text='<%# Bind("safety") %>' />
                      Equipment:
                      <asp:CheckBox ID="equipmentTextBox" runat="server" 
                          Text='<%# Bind("equipment") %>' />
                      <br />
                      
                      <asp:TextBox ID="employeeTextBox" runat="server" Text='<%# Bind("employee") %>' 
                          Visible="False" />
                      <br />
                      
                      <asp:TextBox ID="employee_numberTextBox" runat="server" 
                          Text='<%# Bind("employee_number") %>' Visible="False" />
                      <br />
                      <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                          CommandName="Insert" Text="Insert" />
                      &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                          CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                  </InsertItemTemplate>
                  <ItemTemplate>
                      TimeSheetID:
                      <asp:Label ID="TimeSheetIDLabel" runat="server" 
                          Text='<%# Eval("TimeSheetID") %>' />
                      <br />
                      workperiod:
                      <asp:Label ID="workperiodLabel" runat="server" 
                          Text='<%# Bind("workperiod") %>' />
                      <br />
                      tsdate:
                      <asp:Label ID="tsdateLabel" runat="server" Text='<%# Bind("tsdate") %>' />
                      <br />
                      job_description:
                      <asp:Label ID="job_descriptionLabel" runat="server" 
                          Text='<%# Bind("job_description") %>' />
                      <br />
                      Level:
                      <asp:Label ID="LevelLabel" runat="server" Text='<%# Bind("Level") %>' />
                      <br />
                      workarea:
                      <asp:Label ID="workareaLabel" runat="server" Text='<%# Bind("workarea") %>' />
                      <br />
                      workplace:
                      <asp:Label ID="workplaceLabel" runat="server" Text='<%# Bind("workplace") %>' />
                      <br />
                      grade:
                      <asp:Label ID="gradeLabel" runat="server" Text='<%# Bind("grade") %>' />
                      <br />
                      days:
                      <asp:Label ID="daysLabel" runat="server" Text='<%# Bind("days") %>' />
                      <br />
                      contract:
                      <asp:Label ID="contractLabel" runat="server" Text='<%# Bind("contract") %>' />
                      <br />
                      shift:
                      <asp:Label ID="shiftLabel" runat="server" Text='<%# Bind("shift") %>' />
                      <br />
                      reg:
                      <asp:Label ID="regLabel" runat="server" Text='<%# Bind("reg") %>' />
                      <br />
                      ot1:
                      <asp:Label ID="ot1Label" runat="server" Text='<%# Bind("ot1") %>' />
                      <br />
                      ot2:
                      <asp:Label ID="ot2Label" runat="server" Text='<%# Bind("ot2") %>' />
                      <br />
                      holes:
                      <asp:Label ID="holesLabel" runat="server" Text='<%# Bind("holes") %>' />
                      <br />
                      hole_length:
                      <asp:Label ID="hole_lengthLabel" runat="server" 
                          Text='<%# Bind("hole_length") %>' />
                      <br />
                      powder:
                      <asp:Label ID="powderLabel" runat="server" Text='<%# Bind("powder") %>' />
                      <br />
                      bolts_4:
                      <asp:Label ID="bolts_4Label" runat="server" Text='<%# Bind("bolts_4") %>' />
                      <br />
                      bolts_6:
                      <asp:Label ID="bolts_6Label" runat="server" Text='<%# Bind("bolts_6") %>' />
                      <br />
                      safety:
                      <asp:Label ID="safetyLabel" runat="server" Text='<%# Bind("safety") %>' />
                      <br />
                      equipment:
                      <asp:Label ID="equipmentLabel" runat="server" Text='<%# Bind("equipment") %>' />
                      <br />
                      employee:
                      <asp:Label ID="employeeLabel" runat="server" Text='<%# Bind("employee") %>' />
                      <br />
                      employee_number:
                      <asp:Label ID="employee_numberLabel" runat="server" 
                          Text='<%# Bind("employee_number") %>' />
                      <br />
                      <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                          CommandName="Edit" Text="Edit" />
                      &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                          CommandName="Delete" Text="Delete" />
                      &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                          CommandName="New" Text="New" />
                  </ItemTemplate>
                  <InsertRowStyle HorizontalAlign="Right" />
              </asp:FormView>
              <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                  ConnectionString="<%$ ConnectionStrings:SunshineConnectionString %>" 
                  DeleteCommand="DELETE FROM [TS2008] WHERE [TimeSheetID] = @TimeSheetID" 
                  InsertCommand="INSERT INTO [TS2008] ([workperiod], [tsdate], [employee], [employee_number], [job_description], [workplace], [grade], [days], [contract], [shift], [reg], [ot1], [ot2], [holes], [hole_length], [powder], [bolts_4], [bolts_6], [safety], [equipment]) VALUES (@workperiod, @tsdate, @employee, @employee_number, @job_description, @workplace, @grade, @days, @contract, @shift, @reg, @ot1, @ot2, @holes, @hole_length, @powder, @bolts_4, @bolts_6, @safety, @equipment)" 
                  SelectCommand="SELECT * FROM [TS2008]" 
                  UpdateCommand="UPDATE [TS2008] SET [workperiod] = @workperiod, [tsdate] = @tsdate, [employee] = @employee, [employee_number] = @employee_number, [job_description] = @job_description, [workplace] = @workplace, [grade] = @grade, [days] = @days, [contract] = @contract, [shift] = @shift, [reg] = @reg, [ot1] = @ot1, [ot2] = @ot2, [holes] = @holes, [hole_length] = @hole_length, [powder] = @powder, [bolts_4] = @bolts_4, [bolts_6] = @bolts_6, [safety] = @safety, [equipment] = @equipment WHERE [TimeSheetID] = @TimeSheetID">
                  <DeleteParameters>
                      <asp:Parameter Name="TimeSheetID" Type="Int32" />
                  </DeleteParameters>
                  <UpdateParameters>
                      <asp:Parameter Name="workperiod" Type="String" />
                      <asp:Parameter Name="tsdate" Type="String" />
                      <asp:Parameter Name="employee" Type="String" />
                      <asp:Parameter Name="employee_number" Type="String" />
                      <asp:Parameter Name="job_description" Type="String" />
                      <asp:Parameter Name="workplace" Type="String" />
                      <asp:Parameter Name="grade" Type="String" />
                      <asp:Parameter Name="days" Type="Int32" />
                      <asp:Parameter Name="contract" Type="Int32" />
                      <asp:Parameter Name="shift" Type="String" />
                      <asp:Parameter Name="reg" Type="String" />
                      <asp:Parameter Name="ot1" Type="String" />
                      <asp:Parameter Name="ot2" Type="String" />
                      <asp:Parameter Name="holes" Type="String" />
                      <asp:Parameter Name="hole_length" Type="String" />
                      <asp:Parameter Name="powder" Type="String" />
                      <asp:Parameter Name="bolts_4" Type="String" />
                      <asp:Parameter Name="bolts_6" Type="String" />
                      <asp:Parameter Name="safety" Type="Int32" />
                      <asp:Parameter Name="equipment" Type="Int32" />
                      <asp:Parameter Name="TimeSheetID" Type="Int32" />
                  </UpdateParameters>
                  <InsertParameters>
                      <asp:Parameter Name="workperiod" Type="String" />
                      <asp:Parameter Name="tsdate" Type="String" />
                      <asp:Parameter Name="employee" Type="String" />
                      <asp:Parameter Name="employee_number" Type="String" />
                      <asp:Parameter Name="job_description" Type="String" />
                      <asp:Parameter Name="workplace" Type="String" />
                      <asp:Parameter Name="grade" Type="String" />
                      <asp:Parameter Name="days" Type="Int32" />
                      <asp:Parameter Name="contract" Type="Int32" />
                      <asp:Parameter Name="shift" Type="String" />
                      <asp:Parameter Name="reg" Type="String" />
                      <asp:Parameter Name="ot1" Type="String" />
                      <asp:Parameter Name="ot2" Type="String" />
                      <asp:Parameter Name="holes" Type="String" />
                      <asp:Parameter Name="hole_length" Type="String" />
                      <asp:Parameter Name="powder" Type="String" />
                      <asp:Parameter Name="bolts_4" Type="String" />
                      <asp:Parameter Name="bolts_6" Type="String" />
                      <asp:Parameter Name="safety" Type="Int32" />
                      <asp:Parameter Name="equipment" Type="Int32" />
                  </InsertParameters>
              </asp:SqlDataSource>
Code Behind:
Sub MGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
 
        ' Get the currently selected row using the SelectedRow property.
        Dim mrow As GridViewRow = GridView2.SelectedRow
 
        ' Display the company name from the selected row.
        ' In this example, the third column (index 2) contains
        ' the company name.
        Message2.Text = "You selected " & mrow.Cells(3).Text & "."
        FormView1.FindControl("workperiod") = mrow.Cells(4).Text ,    <- Does not work
 
        'SqlDataSource3.SelectParameters("Employee").DefaultValue = row.Cells(1).Text
 
    End Sub
[+][-]06.20.2008 at 07:22AM PDT, ID: 21831478

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.20.2008 at 09:26AM PDT, ID: 21832689

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for ASP.NET
Tags: Web Developer 2008, IE, intranet
Sign Up Now!
Solution Provided By: joex911
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628