|
widget1 wrote: e_link = CType(FindControl(e_link.ID), HyperLink)
Has e_link been initialized in this statement? You're asking for e_link.ID . That'll throw a null exception if e_link is not initialized.
Logifusion[^]
|
|
|
|
|
I have these loops above it all:
These loops build my table underneath my customized column headers , showing the whole table with the whole grid with white cells and all white hyperlinks one in each cell.
For i As Integer = 0 To dtassessment.Rows.Count - 1
headerrow = New TableRow
headerrow.ID = i.ToString
headerCell = New TableCell
headerCell.Text = dtassessment.Rows(i)("Name").ToString
headerCell.ApplyStyle(tableStyle)
headerrow.Cells.Add(headerCell)
dtoutcomes = Outcome.GetAll(m_connString)
For k As Integer = 0 To dtoutcomes.Rows.Count - 1
'this line fills in the grid on my table
'it also puts a hyperlink in each cell
Dim bodyCell As TableCell
bodyCell = New TableCell
Dim e_link As HyperLink = New HyperLink
e_link.ForeColor() = System.Drawing.Color.White
e_link.ID = "Row=" & i.ToString & "Column=" & k.ToString
e_link.Text = "EDIT"
e_link.NavigateUrl = "Default.aspx"
bodyCell.Controls.Add(e_link)
headerrow.Cells.Add(bodyCell)
Next
MyTable.Rows.Add(headerrow)
Next
headerrow.ApplyStyle(tableStyle)
I next go through my third datatable looking for matches in column and row values and color the cell accordingly. I also want to color the hyperlink inside this cell to match the background color.
'this section brings in my table data and loops through to find matches and place accordingly
For t As Integer = 0 To dttabledata.Rows.Count - 1
For i As Integer = 0 To dtassessment.Rows.Count - 1
If CInt(dttabledata.Rows(t)("Assessment_id")) = CInt(dtassessment.Rows(i)("Assessment_id")) Then
For k As Integer = 0 To dtoutcomes.Rows.Count - 1
If CInt(dttabledata.Rows(t)("Outcome_id")) = CInt(dtoutcomes.Rows(k)("Outcome_id")) Then
MyTable.Rows(i + 1).Cells(k + 1).BackColor = System.Drawing.Color.Black
MyTable.Rows(i + 1).Cells(k + 1).HorizontalAlign = HorizontalAlign.Center
MyTable.Rows(i + 1).Cells(k + 1).ForeColor = System.Drawing.Color.Black
e_link = CType(FindControl("e_link.ID"), HyperLink)***
e_link.ForeColor = System.Drawing.Color.Black
End If
I think I am having the problem that the e-link.ID created above does not hold the value through to the next set of loops?? Not sure how to overcome this problem. How can I maintain the ID value to my next set off loops?
Thx, t
|
|
|
|
|
widget1 wrote: e_link = CType(FindControl("e_link.ID"), HyperLink)
You declare e_link above inside of two for loops. How does this line even compile?
Logifusion[^]
|
|
|
|
|
I am not sure why but won't vb.net compile and then cause the runtime error versus C# which would not even compile? I declared and initialized above the loops now and now I am getting a runtime error on the next line:
**e_link.ForeColor = System.Drawing.Color.Black
Someone told me a linkbutton causes a postback and there are a lot of them on this table so a hyperlink only causes a page refresh which is better in this case.
How can I hold the ID value from the first set of loops into the second?
This is the first thing I have ever made with asp.net and vb.net for that matter.
Tammy
|
|
|
|
|
widget1 wrote: a linkbutton causes a postback and ... a hyperlink only causes a page refresh
Those things are the same in your case. A typical hyperlink should send you to a new page, but you're detecting that it was clicked and handling it server side, which means the form is being submitted.
widget1 wrote: How can I hold the ID value from the first set of loops into the second?
Where you do this:
e_link.ID = "Row=" & i.ToString & "Column=" & k.ToString
You are creating the ID. Simply copy the code you use to create that ID into the second loop:
e_link = CType(FindControl("Row=" & i.ToString & "Column=" & k.ToString), HyperLink)
Logifusion[^]
|
|
|
|
|
Ok I did that but I am still getting this error:
Object reference not set to an instance of an object.
It is highlighting this line:
Line 151: e_link.ForeColor = System.Drawing.Color.Black
I have no idea what is going on excpet I think it is not recognizing the hyperlink located in that cell.
Tammy
|
|
|
|
|
Well, the way you're doing this is going to be difficult. The page might not recognize the control yet enough to find it for you. So you might try going to the table itself:
e_link = CType(MyTable.Rows(i).Cells(k).Controls(0), HyperLink)
Logifusion[^]
|
|
|
|
|
Honestly, I still think you're making this too difficult. You're chaning the IDs of HyperLink s to overcome the fact they don't have a CommandArgument like LinkButton . Where LinkButton produces the same results and is much easier to use in this case.
Logifusion[^]
|
|
|
|
|
hi every one i have a problem, i have developed an asp.net application in which in one page i am showing data in grid and on clicking ID in grid it is opening a pop up window in which i can do some changes in the data base based on that id...
every thing is working fine page is refereshing also on clicking save button on the pop up window but my problem starts ... if i click on the back button of the browser window that pop up window automatically popup and all the fields are filled on the bases of id which i have selected earlier
so how do i solve this problem
plez suggest some answer...
Rohit Daga
|
|
|
|
|
Disable the Back Button click of the browser.U will find Javascript code for the same on google.
Thanks and Regards.
|
|
|
|
|
or you can invalidate pages in history.
in .NET 2.0 it is done by this line of code:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
|
|
|
|
hi all
i need help from all of u ,my question is,i add checkbox in datagrid and check some or all check box in datagrid and click delete button then those datagrid rows are delete from database.
Thanx in advance
your
peter
|
|
|
|
|
According to what i understood,this is how u can implement
foreach (DataGridItem dg in this.dgApproval.Items)
{
int i = 0;
//u use a for loop like this to find the template column of checkbox in data grid
if(((CheckBox)(dg.FindControl("CheckBox1"))).Checked == true)
{
//here i am retreiving the second column of datagrid as i neeeded it
//first column in data grid is the 0th column
string build_desc1=dg.Cells[1].Text.ToString();
//do what u want here... like i have written update query here
string query;
string query2;
query = "update build_master set approval_flag ="+ i +" where build_desc = '"+ build_desc1+"' ";
}
//make sure you bind the grid again to reflect the changes
BindGrid();
}
Happy Programming
Jiny
-- modified at 8:54 Friday 23rd June, 2006
|
|
|
|
|
How do i write javascript to call dll or exe in asp.net web application?
nevinda
|
|
|
|
|
|
How to access the dynamically created ASP.NET 2.0 controls
|
|
|
|
|
Page.FindControl(string controlId);
|
|
|
|
|
Thanks but i found solution, anyway thanks 4 ur time
|
|
|
|
|
|
Thanks 4 u reply and ur link is very usefull and i have found solution in this way u suggested me....
|
|
|
|
|
Hello,
I posted something similar to this post before but this is slightly different.
The GridView gets populated and in the _RowDataBound event the Accept button(select CommandField button) gets replaced by a text value if there is one as shown below:
The find button populated the GridView correctly and Accept button is replaced with a text where necessary but not sure why when the checkbox on the page is clicked on, then ALL the Accept buttons are shown on the GridView (Which is incorrect).
The check box control only shows a label.
Thanks
If (e.Row.RowType = DataControlRowType.DataRow) Then
'show the clinic code since there is a start date other wise just show the Accept button...
'If Not (e.Row.DataItem("c_start_date").ToString() Is Nothing) Then
If Not (e.Row.DataItem("c_start_date").ToString() = "") Then
e.Row.Cells(9).Text = e.Row.DataItem("c_clinic_code").ToString() 'Change ur text here
End If
End If
|
|
|
|
|
That's because you do it in the RowDataBound event handler which basically happens when data is bound to the control. On postback, this method does not execute if you don't bind data, and the button reappear. So like I said in the other post, you should use two controls here and simple use the Visible property to control the visibility of the controls as this property is persisted in the ViewState.
|
|
|
|
|
Hi Developers
I have written code for two way sorting of Datagrid, and its working fine, BUT I want to have two "Arrows"(Upward and Downward) in each column of datagrid. So that when I click on upward arrow grid is sort in Descending and when I click downward arrow grid should be sorted in Ascending Order.
Any code or reference related to this will solve my problem.
Thanks in advance
Lets work it Out.........!
-- modified at 7:20 Friday 23rd June, 2006
|
|
|
|
|
Just use upword and downword arrow Image and attach it to ur code.
ok fine I will send u Image and code just give me ur email.
Balasaheb
Software Developer
Platform: Asp.net,vb.net
Database: SQL Server 2000
|
|
|
|
|
Hi ALl,
Geetings...can anyone help me regarding the Object Data Source control used in asp.net 2.0
Babu
|
|
|
|