Showing posts with label pages. Show all posts
Showing posts with label pages. Show all posts

Thursday, March 8, 2012

Check checkboxes

Hi,

I have two web pages in one web page i have 5 check boxes. For example if the user checks the Checkbox1, checkbox2 and clicks on button.

On the button click I am storing the selected checkboxes value in database lke the following:

Year Options

xxx 1

xxx 2

in the above format( user selectes checbox1, check box 2).

And in the Second Web page I am showing the 5 checkboxes but in this web page I need to check the first and second checkboxes on the page load because user selectes those two check boxes in the first web page.

my select query returning the results like this:

Options

1

2

based on options I have to check those corresponding check boxes in the second web page.

How to achive this.

Thanks in advance

Saving a user's CheckBoxList selection and re-populating the CheckBoxList from saved data:http://www.mikesdotnetting.com/Article.aspx?ArticleID=53

|||

Hello,

You need to loop thru your result set and set the checkboex to Checked on Page_Load event.

For example:

This is how you get the values and set the checkboxes to Checked.

SqlCommand cmd = new SqlCommand("Select OPtions from <Yourtable>...");

SqlDataReader reader =cmd.ExecuteReader();while( reader.Read())

{

int col = reader.GetOrdinal("Options");

int checkValue = reader.GetInt32(col);switch(checkValue)

{

case 1:

CheckBox1.Checked =true;

case 2:

CheckBox2.Checked =true;

... etc

}

}

Optionaly you can use Page.FindControl() method to get to the checkboxes (instead of using switch statement). The problem with that is that FindControl does not loop thru the Page hierarchy so if you page is complex you may have to write your own FindControl method.

Once you have that method you can call it from the Page_Load event, like this:

if (!IsPostback)
{

// Call the SetCheckBoxes method here ...

}

Hope this helps

regards,

G

Wednesday, March 7, 2012

Charts on multiple pages?

Hi All,

I am using SQL Reportig Services 2005 for displaying reports in Bar Graph charts. The problem is that the width of each bar in chart is not fixed and changes based on volume of data. If number of rows retrieved by dataset connection are many, then the graph appears too cramped and is not readable.

Is there any way, programmatically or at design time, that we can change the width of chart based on number of rows retrieved in the dataset?

Any help or reference will be highly appreciated.

Thanks in Advance !!!

Assuming all the data you are showing as bars are really detail rows rather than grouped data, you could consider the following approach:

Add a (detail) group to the list with the following grouping expression:

=Int((RowNumber(Nothing)-1)/20)

As a result you would get 20 detail rows per (repeating) list instance. Then just put the chart inside the list. Those chart instances will never "see" more than 20 detail rows at once.

-- Robert

|||

Thanks Robert !!!

The solution given by you works fine. But I did not get what you mean by 'data you are showing as bars are really detail rows rather than grouped data'.

Is there any limitation to the approach that you have given?

Thanks for reply once again !!!